feat 定时清理库存记录
All checks were successful
Build image / build (push) Successful in 8m34s

This commit is contained in:
timerzz 2024-12-04 13:12:50 +08:00
parent 684cac5eb9
commit bb07b9d61b
2 changed files with 16 additions and 0 deletions

View File

@ -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 // 返回ready
func (c *Controller) Ready() bool { func (c *Controller) Ready() bool {
return c.tracers.Ready() return c.tracers.Ready()

View File

@ -83,6 +83,7 @@ func main() {
wg.Go(spider.Run) wg.Go(spider.Run)
wg.Go(watcher.Run) wg.Go(watcher.Run)
wg.Go(tracer.Run) wg.Go(tracer.Run)
wg.Go(tracer.CleanAts)
// http // http
r := fiber.New(fiber.Config{ErrorHandler: web.ErrHandle}) r := fiber.New(fiber.Config{ErrorHandler: web.ErrHandle})