19 lines
439 B
Go
Raw Permalink Normal View History

2024-12-27 15:56:59 +08:00
package core
import (
"ProjectWIND/LOG"
"ProjectWIND/wba"
"github.com/robfig/cron/v3"
)
2025-02-26 09:07:39 +08:00
func RegisterCron(appNames string, task wba.ScheduledTaskInfo) {
2024-12-27 15:56:59 +08:00
// 注册定时任务
c := cron.New(cron.WithSeconds())
_, err := c.AddFunc(task.Cron, task.Task)
if err != nil {
2025-02-26 09:07:39 +08:00
LOG.Error("添加定时任务 [%s]%s 时出错%v:", appNames, task.Name, err)
2024-12-27 15:56:59 +08:00
}
c.Start()
2025-02-26 09:07:39 +08:00
LOG.Info("定时任务 [%s]%s 注册成功", appNames, task.Name)
2024-12-27 15:56:59 +08:00
}