forked from seefan/monitor
/
main.go
executable file
·50 lines (47 loc) · 1.15 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
package main
import (
// "io/ioutil"
"monitor/cache"
"monitor/common"
"monitor/config"
"monitor/dispatcher"
"runtime"
"time"
)
func main() {
runtime.GOMAXPROCS(common.MaxCPU)
println("cpu num is ", common.MaxCPU)
cfg, err := config.Read("config.xml")
if err != nil {
panic(err.Error())
}
rcfg, err := config.ReadRelation("relation.xml")
if err != nil {
panic(err.Error())
}
cache.Init(cfg, rcfg)
LoadBaseData()
dispatcher.Start(cfg)
time.Sleep(time.Hour)
//if str, err := ioutil.ReadFile("config/config.xml"); err == nil {
// ioutil.WriteFile("config.xml", str, os.ModePerm)
//} else {
// panic(err.Error())
//}//
//test.Test_Dispatcher()
//test.Test_MutiCache()
//test.Test_Push()
//test.Test_WebSocket()
a, err := time.Parse(common.TimeFormat, "2014-02-12 12:59")
b, err := time.Parse(common.TimeFormat, "2014-02-12 13:00")
println(a.Before(b), err)
println(a.After(b))
println(a.Sub(b))
println(a.String())
println(b.String())
}
func LoadBaseData() {
cache.Set("Relation:1", []string{"1", "2", "3", "4", "5"})
cache.Set("Relation:11", []string{"1", "2", "3", "4", "5"})
cache.Set("Relation:2", []string{"1", "2", "3", "4", "5"})
}