Skip to content

Commit

Permalink
feat: rerun cronjob at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed May 18, 2023
1 parent 7857724 commit b480fe9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/task.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package lib

import (
"context"
"strings"

"github.com/disgoorg/log"
"github.com/nezuchan/scheduled-tasks/broker"
"github.com/nezuchan/scheduled-tasks/config"
Expand Down Expand Up @@ -35,6 +38,14 @@ func InitTask(conf *config.Config) *Task {
}

processor.ProcessJob(task.Redis, *task.Broker.Channel); broker.HandleReceive(task.Redis, *task.Broker)
// TODO: Run existing cron job tasks

Members := task.Redis.SMembers(context.Background(), constants.TASK_REDIS_CRON_SETS).Val()

for _, member := range Members {
taskId := strings.Split(member, ":")[0]
name := strings.Split(member, ":")[1]

processor.ProcessCronJob(task.Redis, *task.Broker.Channel, name, taskId)
}
return &task
}

0 comments on commit b480fe9

Please sign in to comment.