-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcube.go
46 lines (36 loc) · 833 Bytes
/
cube.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
package cube
import (
"os"
"os/signal"
log "github.com/sirupsen/logrus"
"github.com/skeletongo/cube/g"
"github.com/skeletongo/cube/module"
"github.com/skeletongo/cube/network"
"github.com/skeletongo/cube/statsviz"
"github.com/skeletongo/cube/timer"
)
func Run() {
log.Infof("Cube %v starting up", Version)
// 需要启用的功能模块
Register(module.Config)
Register(network.Config)
Register(statsviz.Config)
// 读取配置文件,模块初始化
Load()
defer func() {
Close()
log.Infoln("Cube closed")
}()
timer.SetObject(module.Obj)
g.SetObject(module.Obj)
module.Start()
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, os.Kill)
sig := <-c
log.Infof("Cube closing down (signal: %v)", sig)
module.Close()
g.Close()
timer.StopAll()
module.Obj.Close()
<-module.Obj.Closed
}