This commit is contained in:
parent
684cac5eb9
commit
bb07b9d61b
@ -61,6 +61,21 @@ func (c *Controller) Run() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// 清理24小时前的ProviderAts
|
||||
func (c *Controller) CleanAts() error {
|
||||
ticker := time.NewTicker(24 * time.Hour)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-c.ctx.Done():
|
||||
glog.Infof("cleaner退出")
|
||||
return nil
|
||||
case <-ticker.C:
|
||||
c.storage.DB().Delete(v2.ProviderAts{}, "created_at < ?", time.Now().Add(-24*time.Hour))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回ready
|
||||
func (c *Controller) Ready() bool {
|
||||
return c.tracers.Ready()
|
||||
|
@ -83,6 +83,7 @@ func main() {
|
||||
wg.Go(spider.Run)
|
||||
wg.Go(watcher.Run)
|
||||
wg.Go(tracer.Run)
|
||||
wg.Go(tracer.CleanAts)
|
||||
|
||||
// http
|
||||
r := fiber.New(fiber.Config{ErrorHandler: web.ErrHandle})
|
||||
|
Loading…
Reference in New Issue
Block a user