forked from Cepave/open-falcon-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (51 loc) · 1.2 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
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"github.com/Cepave/open-falcon-backend/common/logruslog"
"github.com/Cepave/open-falcon-backend/common/vipercfg"
"github.com/Cepave/open-falcon-backend/modules/alarm/cron"
"github.com/Cepave/open-falcon-backend/modules/alarm/g"
"github.com/Cepave/open-falcon-backend/modules/alarm/http"
"github.com/Cepave/open-falcon-backend/modules/alarm/model"
"github.com/spf13/pflag"
)
func main() {
vipercfg.Parse()
vipercfg.Bind()
if vipercfg.Config().GetBool("version") {
fmt.Println(g.VERSION)
os.Exit(0)
}
if vipercfg.Config().GetBool("help") {
pflag.Usage()
os.Exit(0)
}
vipercfg.Load()
g.ParseConfig(vipercfg.Config().GetString("config"))
logruslog.Init()
g.InitRedisConnPool()
model.InitDatabase()
go http.Start()
go cron.ReadHighEvent()
go cron.ReadLowEvent()
go cron.CombineSms()
go cron.CombineMail()
go cron.CombineQQ()
go cron.CombineServerchan()
// read external alarms
if g.Config().Redis.ExternalQueues.Enable {
go cron.ReadExternalEvent()
}
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigs
fmt.Println()
g.RedisConnPool.Close()
os.Exit(0)
}()
select {}
}