This commit is contained in:
Daniel 2025-05-17 17:47:36 +08:00
parent 7120e1e8ae
commit 31c7fd13b6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -52,6 +52,16 @@ func StartCron() {
func every(interval time.Duration, f func(), name ...string) {
util.RandomSleep(50, 200)
// 启动后立即执行一次
func() {
defer logging.Recover()
f()
if 0 < len(name) {
logging.LogInfof("cron job [%s] executed", name)
}
}()
ticker := time.NewTicker(interval)
defer ticker.Stop()
for range ticker.C {