MCPcopy
hub / github.com/CodisLabs/codis / main

Function main

cmd/dashboard/main.go:25–186  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func main() {
26 const usage = `
27Usage:
28 codis-dashboard [--ncpu=N] [--config=CONF] [--log=FILE] [--log-level=LEVEL] [--host-admin=ADDR] [--pidfile=FILE] [--zookeeper=ADDR|--etcd=ADDR|--filesystem=ROOT] [--product_name=NAME] [--product_auth=AUTH] [--remove-lock]
29 codis-dashboard --default-config
30 codis-dashboard --version
31
32Options:
33 --ncpu=N set runtime.GOMAXPROCS to N, default is runtime.NumCPU().
34 -c CONF, --config=CONF run with the specific configuration.
35 -l FILE, --log=FILE set path/name of daliy rotated log file.
36 --log-level=LEVEL set the log-level, should be INFO,WARN,DEBUG or ERROR, default is INFO.
37`
38
39 d, err := docopt.Parse(usage, nil, true, "", false)
40 if err != nil {
41 log.PanicError(err, "parse arguments failed")
42 }
43
44 switch {
45
46 case d["--default-config"]:
47 fmt.Println(topom.DefaultConfig)
48 return
49
50 case d["--version"].(bool):
51 fmt.Println("version:", utils.Version)
52 fmt.Println("compile:", utils.Compile)
53 return
54
55 }
56
57 if s, ok := utils.Argument(d, "--log"); ok {
58 w, err := log.NewRollingFile(s, log.DailyRolling)
59 if err != nil {
60 log.PanicErrorf(err, "open log file %s failed", s)
61 } else {
62 log.StdLog = log.New(w, "")
63 }
64 }
65 log.SetLevel(log.LevelInfo)
66
67 if s, ok := utils.Argument(d, "--log-level"); ok {
68 if !log.SetLevelString(s) {
69 log.Panicf("option --log-level = %s", s)
70 }
71 }
72
73 if n, ok := utils.ArgumentInteger(d, "--ncpu"); ok {
74 runtime.GOMAXPROCS(n)
75 } else {
76 runtime.GOMAXPROCS(runtime.NumCPU())
77 }
78 log.Warnf("set ncpu = %d", runtime.GOMAXPROCS(0))
79
80 config := topom.NewDefaultConfig()
81 if s, ok := utils.Argument(d, "--config"); ok {
82 if err := config.LoadFromFile(s); err != nil {

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CloseMethod · 0.95
ReleaseMethod · 0.95
PanicErrorMethod · 0.80
PrintlnMethod · 0.80
PanicErrorfMethod · 0.80
SetLevelMethod · 0.80
SetLevelStringMethod · 0.80
PanicfMethod · 0.80
WarnfMethod · 0.80
WarnErrorfMethod · 0.80
SleepMethod · 0.65

Tested by

no test coverage detected