-
Notifications
You must be signed in to change notification settings - Fork 9
/
init.go
60 lines (46 loc) · 957 Bytes
/
init.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
package actor
import (
"flag"
"github.com/davyxu/actornet/util"
"github.com/davyxu/golog"
)
var (
OnReset util.Delegate
exitSignal chan int
)
const colorDefine = `
{
"Rule":[
{"Text":"panic:","Color":"Red"},
{"Text":"[DB]","Color":"Green"},
{"Text":"#recv","Color":"Blue"},
{"Text":"#send","Color":"Purple"},
{"Text":"#connected","Color":"Blue"},
{"Text":"#listen","Color":"Blue"},
{"Text":"#accepted","Color":"Blue"},
{"Text":"#closed","Color":"Blue"},
{"Text":"#notify","Color":"White"},
{"Text":"#spawn","Color":"DarkGreen"}
]
}
`
func StartSystem() {
// 非测试环境时, 打开加色
if flag.Lookup("test.v") == nil {
golog.SetColorDefine("*", colorDefine)
golog.EnableColorLogger("*", true)
}
OnReset.Invoke()
exitSignal = make(chan int)
}
// 退出
func Exit(exitcode int) {
exitSignal <- exitcode
}
func LoopSystem() int {
return <-exitSignal
}
var inited bool
func init() {
inited = true
}