Browse Source

修复调试发现的问题

gitlink
Sydonian 2 years ago
parent
commit
d50f05ed21
1 changed files with 18 additions and 3 deletions
  1. +18
    -3
      main.go

+ 18
- 3
main.go View File

@@ -33,14 +33,15 @@ func main() {
log.Fatalf("new db failed, err: %s", err.Error())
}

wg := sync.WaitGroup{}
wg.Add(3)

distlockSvc, err := distlocksvc.NewService(&config.Cfg().DistLock)
if err != nil {
log.Warnf("new distlock service failed, err: %s", err.Error())
os.Exit(1)
}

wg := sync.WaitGroup{}
wg.Add(2)
go serveDistLock(distlockSvc, &wg)

eventExecutor := event.NewExecutor(db, distlockSvc)
go serveEventExecutor(&eventExecutor, &wg)
@@ -91,6 +92,20 @@ func serveScannerServer(server *scsvr.Server, wg *sync.WaitGroup) {
wg.Done()
}

func serveDistLock(svc *distlocksvc.Service, wg *sync.WaitGroup) {
log.Info("start serving distlock")

err := svc.Serve()

if err != nil {
log.Errorf("distlock stopped with error: %s", err.Error())
}

log.Info("distlock stopped")

wg.Done()
}

func startTickEvent(tickExecutor *tickevent.Executor) {
// TODO 可以考虑增加配置文件,配置这些任务间隔时间



Loading…
Cancel
Save