优化代码/增加edge-api goman命令

This commit is contained in:
刘祥超
2021-12-14 10:49:29 +08:00
parent 59ce71f72e
commit 3ff6ca5905
54 changed files with 383 additions and 131 deletions

View File

@@ -2,6 +2,7 @@ package models
import (
"github.com/TeaOSLab/EdgeAPI/internal/errors"
"github.com/TeaOSLab/EdgeAPI/internal/goman"
"github.com/TeaOSLab/EdgeAPI/internal/utils"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
_ "github.com/go-sql-driver/mysql"
@@ -21,14 +22,14 @@ func init() {
dbs.OnReadyDone(func() {
// 清理数据任务
var ticker = time.NewTicker(time.Duration(rands.Int(24, 48)) * time.Hour)
go func() {
goman.New(func() {
for range ticker.C {
err := SharedServerDailyStatDAO.Clean(nil, 30) // 只保留N天
if err != nil {
logs.Println("ServerDailyStatDAO", "clean expired data failed: "+err.Error())
}
}
}()
})
})
}