forked from Cepave/open-falcon-backend
/
main.go
65 lines (55 loc) · 1.38 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
package main
import (
"fmt"
"os"
"os/signal"
"github.com/Cepave/open-falcon-backend/common/logruslog"
"github.com/Cepave/open-falcon-backend/common/vipercfg"
"github.com/Cepave/open-falcon-backend/modules/fe/cache"
"github.com/Cepave/open-falcon-backend/modules/fe/g"
"github.com/Cepave/open-falcon-backend/modules/fe/graph"
"github.com/Cepave/open-falcon-backend/modules/fe/grpc"
"github.com/Cepave/open-falcon-backend/modules/fe/http"
"github.com/Cepave/open-falcon-backend/modules/fe/http/portal"
"github.com/Cepave/open-falcon-backend/modules/fe/model"
"github.com/Cepave/open-falcon-backend/modules/fe/mq"
log "github.com/sirupsen/logrus"
"github.com/toolkits/logger"
)
func main() {
vipercfg.Parse()
vipercfg.Bind()
if vipercfg.Config().GetBool("version") {
fmt.Println(g.VERSION)
os.Exit(0)
}
// parse config
vipercfg.Load()
if err := g.ParseConfig(vipercfg.Config().GetString("config")); err != nil {
log.Fatalln(err)
}
logruslog.Init()
conf := g.Config()
logger.SetLevelWithDefault(g.Config().Log, "info")
model.InitDatabase()
cache.InitCache()
if conf.Grpc.Enabled {
graph.Start()
go grpc.Start()
}
if conf.Mq.Enabled {
go mq.Start()
}
if conf.Http.Enabled {
go http.Start()
go portal.CornDaemonStart()
}
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
select {
case sig := <-c:
if sig.String() == "^C" {
os.Exit(3)
}
}
}