-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain.go
83 lines (66 loc) · 1.08 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
package main
import (
"flag"
"fmt"
"go-box/api"
"go-box/common"
"go-box/core"
"go-box/db"
"go-box/file"
"go-box/micro"
"os"
"github.com/labstack/echo"
)
const (
version = "0.1"
)
var (
// Build information should only be set by -ldflags.
BuildDate string
BuildGitHash string
h bool
v bool
cfgpath string
e *echo.Echo
)
func cmd() {
flag.BoolVar(&h, "h", false, "this help")
flag.BoolVar(&v, "v", false, "show version")
flag.StringVar(&cfgpath, "c", "config.json", "set cfg and start")
flag.Parse()
if v {
fmt.Println("Version:", version)
if len(BuildDate) > 0 {
fmt.Println("BuildDate:", BuildDate)
fmt.Println("BuildGitHash:", BuildGitHash)
}
os.Exit(0)
}
if h {
flag.Usage()
os.Exit(0)
}
}
func main() {
// cmd
cmd()
// config
common.InitConfig(cfgpath)
// db
db.InitDB()
// file
file.InitFile()
// core
core.InitCore()
// api
api.InitApi()
// ws
common.InitWS()
// grpc
config := common.GlobalConfig
if config.GrpcEnable {
micro.RunGrpc(config.GrpcAddr)
}
// this will block forever
api.StartAPP()
}