Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
package job
import (
"context"
"time"
"91porn-server/common/log"
"github.com/robfig/cron/v3"
)
var statCron *cron.Cron
func init() {
statCron = cron.New(cron.WithSeconds()) //从秒开始的定时任务
}
// 开启定时任务
func Start() {
log.Info("start job...", log.Any("beginAt", time.Now()))
start()
}
func Stop() {
ctx := statCron.Stop()
<-ctx.Done()
err := ctx.Err()
//statCron.Stop()后,若job处于静默可能立即退出,再次执行<-ctx.Done()产生Canceled错误,此处忽略该错误
if err != nil && err != context.Canceled {
log.Error("Skd Job Stop error", log.E(err))
return
}
log.Info("end job", log.Any("endAt", time.Now()))
}