This commit is contained in:
2026-08-16 22:38:44 +08:00
parent 1945d34894
commit 560ae46b82
19 changed files with 345 additions and 112 deletions
+3 -4
View File
@@ -48,17 +48,16 @@ func (s *TaskScheduler) Start(ctx context.Context) error {
s.seconds.Start()
items, _, err := s.tasks.ListTasks(ctx, 0, 0, nil)
if err == nil {
loaded := 0
for _, task := range items {
if task.Enabled {
if scheduleErr := s.Schedule(task); scheduleErr != nil {
s.logger.ErrorContext(ctx, "restore timed task failed", "id", task.ID, "error", scheduleErr)
} else {
loaded++
}
}
}
s.logger.InfoContext(ctx, "定时任务加载完成", "task_count", loaded)
// GVA reports the number of rows read from the database, not only
// the enabled rows that were scheduled successfully.
s.logger.InfoContext(ctx, "定时任务加载完成", "task_count", len(items))
} else {
s.logger.WarnContext(ctx, "timed task table is not ready", "error", err)
}