-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (44 loc) · 1.13 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
package main
import (
"log"
"slow-log-tail/config"
"slow-log-tail/datasource"
"slow-log-tail/model"
"slow-log-tail/parsefile"
)
func main() {
log.Println("Start parse config file and Connect to the specified database.")
config := config.GetConfig()
var sender model.Sender
switch config.OutPutType {
case "mysql":
//fmt.Println("mysql")
//解析配置文件 、 连接数据库
datasource.InitDB()
sender = &model.Mysql{Db: datasource.GetDB()}
case "post":
//fmt.Println("post")
sender = &model.Post{
Host: config.Post.Host,
Url: config.Post.Url,
}
}
log.Println("Start parse the slow log file.")
//fmt.Println(config.GetConfig().SlowLog.IgnoreUser)
parsefile.ParseTail(config, sender)
//ctxMain, _ := context.WithCancel(context.Background())
//
//ctx, cancel := context.WithCancel(context.Background())
//
//keyChan := make(chan string, 10)
//
//go parsefile.WatchLogFile(config, sender, ctx, keyChan)
//
//defer func() {
// if err := recover(); err != nil {
// fmt.Println("main goroutine panic ", err) // 这里的err其实就是panic传入的内容
// }
// cancel()
//}()
//<-ctxMain.Done()
}