-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
83 lines (65 loc) · 1.56 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"fmt"
"github.com/astaxie/beego/logs"
"github.com/rh01/logagent/kafka"
)
func main() {
// 读取配置
filename := "./conf/logcollect.conf"
err := LoadConf("ini", filename)
if err != nil {
fmt.Printf("load conf failed, err: %v\n", err)
panic("load conf failed")
}
//初始化配置
err = InitLogger()
if err != nil {
fmt.Printf("load conf failed, err: %v\n", err)
panic(err)
return
}
logs.Debug("initial success!")
logs.Debug("logs filename: %v", AppConfig)
// 初始化kafka配置
// 参考:
err = kafka.InitKafka(AppConfig.kafkaAddr)
if err != nil {
logs.Error("init kafka failed, error %v", err)
return
}
collectConf, err := initEtcd(AppConfig.etcdAddrr, AppConfig.configKey)
if err != nil {
logs.Error("init etcd failed, err %v", err)
return
}
// 初始化tailf配置
// Refer this document: https://github.com/hpcloud/tail
err = InitTail(collectConf, AppConfig.ChanSize)
if err != nil {
logs.Error("init tail failed, error %v", err)
return
}// 初始化tailf配置
// Refer this document: https://github.com/hpcloud/tail
err = InitTail(AppConfig.collectConf, AppConfig.ChanSize)
if err != nil {
logs.Error("init tail failed, error %v", err)
return
}
logs.Debug("init all success...")
// 测试
/*go func() {
var count int
for {
logs.Debug("test for logger %d", count)
count++
time.Sleep(time.Millisecond * 10)
}
}()*/
// 真正的业务逻辑处理函数
err = ServerRun()
if err != nil {
logs.Error("server run failed ...")
}
logs.Info("program exited...")
}