/
main.go
39 lines (36 loc) · 974 Bytes
/
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
package main
import (
"config"
"flag"
"fmt"
"lib/logger"
"repo/store"
"server"
)
var (
configFile = flag.String("c", "./conf/hub.toml.dev", "config file path")
)
func main() {
flag.Parse()
//init
if err := config.Init(*configFile); err != nil {
fmt.Printf("config load err:%s", err.Error())
return
}
fmt.Printf("config load success.\n%s\n", config.String())
if err := logger.Init(config.Global.Log.FilePath, config.Global.Debug); err != nil {
fmt.Printf("logger load err:%s", err.Error())
return
}
fmt.Println("logger load success.")
storeConf := config.Global.Store
if err := store.Init(storeConf.Host, storeConf.Pool.MinOpen, storeConf.Pool.MaxOpen,
storeConf.Pool.MaxLifeTime, storeConf.Pool.Timeout); err != nil {
fmt.Printf("store init err:%s", err.Error())
return
}
fmt.Println("store load success.")
if err := server.Listen(config.Global.Grpc.Addr); err != nil {
logger.Error("hub server start error. err:%s", err.Error())
}
}