forked from keploy/keploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
executable file
·92 lines (81 loc) · 3.18 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Package main is the entry point for the keploy application.
package main
import (
"context"
"fmt"
"os"
"syscall"
"go.keploy.io/server/v2/cli"
"go.keploy.io/server/v2/cli/provider"
"go.keploy.io/server/v2/config"
"go.keploy.io/server/v2/pkg/platform/yaml/configdb"
"go.keploy.io/server/v2/utils"
"go.keploy.io/server/v2/utils/log"
//pprof for debugging
// _ "net/http/pprof"
)
// version is the version of the server and will be injected during build by ldflags, same with dsn
// see https://goreleaser.com/customization/build/
var version string
var dsn string
const logo string = `
▓██▓▄
▓▓▓▓██▓█▓▄
████████▓▒
▀▓▓███▄ ▄▄ ▄ ▌
▄▌▌▓▓████▄ ██ ▓█▀ ▄▌▀▄ ▓▓▌▄ ▓█ ▄▌▓▓▌▄ ▌▌ ▓
▓█████████▌▓▓ ██▓█▄ ▓█▄▓▓ ▐█▌ ██ ▓█ █▌ ██ █▌ █▓
▓▓▓▓▀▀▀▀▓▓▓▓▓▓▌ ██ █▓ ▓▌▄▄ ▐█▓▄▓█▀ █▓█ ▀█▄▄█▀ █▓█
▓▌ ▐█▌ █▌
▓
`
func main() {
// Uncomment the following code to enable pprof for debugging
// go func() {
// fmt.Println("Starting pprof server for debugging...")
// http.ListenAndServe("localhost:6060", nil)
// }()
printLogo()
ctx := utils.NewCtx()
start(ctx)
}
func printLogo() {
if version == "" {
version = "2-dev"
}
utils.Version = version
if binaryToDocker := os.Getenv("BINARY_TO_DOCKER"); binaryToDocker != "true" {
fmt.Println(logo, " ")
fmt.Printf("version: %v\n\n", version)
}
}
func start(ctx context.Context) {
logger, err := log.New()
if err != nil {
fmt.Println("Failed to start the logger for the CLI", err)
return
}
defer utils.DeleteLogs(logger)
defer utils.Recover(logger)
// The 'umask' command is commonly used in various operating systems to regulate the permissions of newly created files.
// These 'umask' values subtract from the permissions assigned by the process, effectively lowering the permissions.
// For example, if a file is created with permissions '777' and the 'umask' is '022', the resulting permissions will be '755',
// reducing certain permissions for security purposes.
// Setting 'umask' to '0' ensures that 'keploy' can precisely control the permissions of the files it creates.
// However, it's important to note that this approach may not work in scenarios involving mounted volumes,
// as the 'umask' is set by the host system, and cannot be overridden by 'keploy' or individual processes.
oldMask := syscall.Umask(0)
defer syscall.Umask(oldMask)
configDb := configdb.NewConfigDb(logger)
if dsn != "" {
utils.SentryInit(logger, dsn)
//logger = utils.ModifyToSentryLogger(ctx, logger, sentry.CurrentHub().Client(), configDb)
}
conf := config.New()
svcProvider := provider.NewServiceProvider(logger, configDb, conf)
cmdConfigurator := provider.NewCmdConfigurator(logger, conf)
rootCmd := cli.Root(ctx, logger, svcProvider, cmdConfigurator)
if err := rootCmd.Execute(); err != nil {
os.Exit(1)
}
}