Fetch the repository succeeded.
package xcron
import (
"time"
"github.com/robfig/cron/v3"
)
// 重启定时任务【会移除所有的定时任务ID,然后重新插入】
//
// 此处采用停止清空的形式来重启
func Restart() {
// 停止定时任务
_default.Lock()
defer _default.Unlock()
if _default.cron != nil {
_default.cron.Stop()
for i := 0; i < len(_default.Tables); i++ {
_default.Tables[i].ExecId = 0
}
_default.cron = nil
}
// 开启新的定时任务
_default.cron = cron.New()
for k, v := range _default.Tables {
if v.IsPause {
continue
}
_default.Tables[k].StartTime = time.Now().Format(time.DateTime)
id, err := _default.cron.AddFunc(v.Spec, v.Func)
if err != nil {
_default.Tables[k].Error = err.Error()
} else {
_default.Tables[k].ExecId = id
}
}
_default.cron.Start()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。