-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (36 loc) · 1.12 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
package main
import (
"flag"
"log"
"qb-helper/cleaner"
"qb-helper/config"
"time"
"github.com/xxxsen/common/logger"
"go.uber.org/zap"
)
var cfg = flag.String("config", "./config.json", "config file")
func main() {
flag.Parse()
conf, err := config.Parse(*cfg)
if err != nil {
log.Fatalf("Parse config fail, err:%v", err)
}
//init log
logkit := logger.Init(conf.LogConfig.File, conf.LogConfig.Level, int(conf.LogConfig.FileCount), int(conf.LogConfig.FileSize), int(conf.LogConfig.KeepDays), conf.LogConfig.Console)
logkit.Info("recv config", zap.Any("config", conf))
svc, err := cleaner.New(
cleaner.WithQBConfig(conf.QBConfig.Host, conf.QBConfig.Username, conf.QBConfig.Password),
cleaner.WithInterval(time.Duration(conf.Interval)*time.Second),
cleaner.WithAddUaRule(conf.BlacklistUa...),
cleaner.WithAddIPRule(conf.BlacklistIP...),
cleaner.WithAddPeerIDRule(conf.BlacklistPeerID...),
cleaner.WithAddRegionRule(conf.BlacklistRegion...),
)
if err != nil {
logkit.Fatal("init cleaner failed", zap.Error(err))
}
if err := svc.Start(); err != nil {
logkit.Fatal("run cleaner failed", zap.Error(err))
}
select {}
}