-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
104 lines (95 loc) · 2.03 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
93
94
95
96
97
98
99
100
101
102
103
104
package main
import (
"fmt"
"os"
"runtime"
"github.com/urfave/cli"
"DVT_Service/cliCmd"
"DVT_Service/common"
"DVT_Service/conf"
)
func setupApp() *cli.App {
app := cli.NewApp()
app.Usage = "DVT Service"
app.Action = cliCmd.StartProducerServer
app.Version = "1.0.0"
app.Commands = []cli.Command{
cliCmd.Consumer,
}
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
EnvVar: "CONFIG_FILE_PATH",
Usage: "Service config file `<path>`",
Value: "",
},
// NACOS
cli.StringFlag{
Name: conf.NacosUrl,
EnvVar: conf.NacosUrl,
},
cli.StringFlag{
Name: conf.NacosNamespaceId,
EnvVar: conf.NacosNamespaceId,
},
cli.StringFlag{
Name: conf.NacosDataId,
EnvVar: conf.NacosDataId,
},
cli.StringFlag{
Name: conf.NacosGroup,
EnvVar: conf.NacosGroup,
Value: "DEFAULT_GROUP",
},
cli.StringFlag{
Name: conf.NacosUsername,
EnvVar: conf.NacosUsername,
},
cli.StringFlag{
Name: conf.NacosPassword,
EnvVar: conf.NacosPassword,
},
// Mysql Password
cli.StringFlag{
Name: conf.MysqlPassword,
EnvVar: conf.MysqlPassword,
},
// Redis Password
cli.StringFlag{
Name: conf.RedisPassword,
EnvVar: conf.RedisPassword,
},
// Keystore Secret Key
cli.StringFlag{
Name: conf.KeystoreSecretKey,
EnvVar: conf.KeystoreSecretKey,
},
}
app.Before = func(context *cli.Context) error {
cpuNum := 0
if runtime.NumCPU() > 4 {
cpuNum = 4
} else {
cpuNum = runtime.NumCPU()
}
runtime.GOMAXPROCS(cpuNum)
return nil
}
return app
}
// @title DVT Service API
// @version 1.0.0
// @description This is a sample server celler server.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {
common.InitLogger("logs/dvt_service.log")
if err := setupApp().Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}