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

Function main

cmd/fe/main.go:56–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54}
55
56func main() {
57 const usage = `
58Usage:
59 codis-fe [--ncpu=N] [--log=FILE] [--log-level=LEVEL] [--assets-dir=PATH] [--pidfile=FILE] (--dashboard-list=FILE|--zookeeper=ADDR [--zookeeper-auth=USR:PWD]|--etcd=ADDR [--etcd-auth=USR:PWD]|--filesystem=ROOT) --listen=ADDR
60 codis-fe --version
61
62Options:
63 --ncpu=N set runtime.GOMAXPROCS to N, default is runtime.NumCPU().
64 -d FILE, --dashboard-list=FILE set list of dashboard, can be generated by codis-admin.
65 -l FILE, --log=FILE set path/name of daliy rotated log file.
66 --log-level=LEVEL set the log-level, should be INFO,WARN,DEBUG or ERROR, default is INFO.
67 --listen=ADDR set the listen address.
68`
69 d, err := docopt.Parse(usage, nil, true, "", false)
70 if err != nil {
71 log.PanicError(err, "parse arguments failed")
72 }
73
74 if d["--version"].(bool) {
75 fmt.Println("version:", utils.Version)
76 fmt.Println("compile:", utils.Compile)
77 return
78 }
79
80 if s, ok := utils.Argument(d, "--log"); ok {
81 w, err := log.NewRollingFile(s, log.DailyRolling)
82 if err != nil {
83 log.PanicErrorf(err, "open log file %s failed", s)
84 } else {
85 log.StdLog = log.New(w, "")
86 }
87 }
88 log.SetLevel(log.LevelInfo)
89
90 if s, ok := utils.Argument(d, "--log-level"); ok {
91 if !log.SetLevelString(s) {
92 log.Panicf("option --log-level = %s", s)
93 }
94 }
95
96 if n, ok := utils.ArgumentInteger(d, "--ncpu"); ok {
97 runtime.GOMAXPROCS(n)
98 } else {
99 runtime.GOMAXPROCS(runtime.NumCPU())
100 }
101 log.Warnf("set ncpu = %d", runtime.GOMAXPROCS(0))
102
103 listen := utils.ArgumentMust(d, "--listen")
104 log.Warnf("set listen = %s", listen)
105
106 var assets string
107 if s, ok := utils.Argument(d, "--assets-dir"); ok {
108 abspath, err := filepath.Abs(s)
109 if err != nil {
110 log.PanicErrorf(err, "get absolute path of %s failed", s)
111 }
112 assets = abspath
113 } else {

Callers

nothing calls this directly

Calls 14

CloseMethod · 0.95
GetNamesMethod · 0.95
GetProxyMethod · 0.95
NewReverseProxyFunction · 0.85
PanicErrorMethod · 0.80
PrintlnMethod · 0.80
PanicErrorfMethod · 0.80
SetLevelMethod · 0.80
SetLevelStringMethod · 0.80
PanicfMethod · 0.80
WarnfMethod · 0.80
WarnErrorfMethod · 0.80

Tested by

no test coverage detected