diff --git a/ats-tracer/controller.go b/ats-tracer/controller.go index 4d9c7c0..f09ad9b 100644 --- a/ats-tracer/controller.go +++ b/ats-tracer/controller.go @@ -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() diff --git a/cmd/main.go b/cmd/main.go index 2d50f41..a429d3d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -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})