:art:监听任务更改为定时任务
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
coward
2024-06-13 17:06:23 +08:00
parent 073bcc4a1d
commit a424a5e0b3
6 changed files with 39 additions and 6 deletions

17
cron_task/cron.go Normal file
View File

@@ -0,0 +1,17 @@
package cron_task
import (
"gitee.ltd/lxh/logger/log"
"github.com/go-co-op/gocron/v2"
"time"
)
func StartCronTask() {
s, err := gocron.NewScheduler()
if err != nil {
log.Errorf("初始化定时任务失败: %v", err.Error())
return
}
_, _ = s.NewJob(gocron.DurationJob(time.Hour), gocron.NewTask(offlineMonitoring)) // 每小时执行一次
s.Start()
}