Merge branch 'feature/fix-schedule-when-init-branch-launch' of https://github.com/helloannali/Shuffle into helloannali-feature/fix-schedule-when-init-branch-launch

This commit is contained in:
frikky
2021-07-30 19:54:51 +02:00
+13 -9
View File
@@ -3973,15 +3973,10 @@ func runInitEs(ctx context.Context) {
log.Printf("[WARNING] Failed getting schedules during service init: %s", err) log.Printf("[WARNING] Failed getting schedules during service init: %s", err)
} else { } else {
log.Printf("[INFO] Setting up %d schedule(s)", len(schedules)) log.Printf("[INFO] Setting up %d schedule(s)", len(schedules))
url := &url.URL{}
for _, schedule := range schedules {
if schedule.Environment == "cloud" {
log.Printf("Skipping cloud schedule")
continue
}
//log.Printf("Schedule: %#v", schedule) url := &url.URL{}
job := func() { job := func(schedule ScheduleOld) func() {
return func() {
//log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds) //log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds)
//log.Printf("ARG: %s", schedule.WrappedArgument) //log.Printf("ARG: %s", schedule.WrappedArgument)
@@ -3996,9 +3991,18 @@ func runInitEs(ctx context.Context) {
log.Printf("[WARNING] Failed to execute %s: %s", schedule.WorkflowId, err) log.Printf("[WARNING] Failed to execute %s: %s", schedule.WorkflowId, err)
} }
} }
}
for _, schedule := range schedules {
if schedule.Environment == "cloud" {
log.Printf("Skipping cloud schedule")
continue
}
//log.Printf("Schedule: %#v", schedule)
//log.Printf("Schedule time: every %d seconds", schedule.Seconds) //log.Printf("Schedule time: every %d seconds", schedule.Seconds)
jobret, err := newscheduler.Every(schedule.Seconds).Seconds().NotImmediately().Run(job) jobret, err := newscheduler.Every(schedule.Seconds).Seconds().NotImmediately().Run(job(schedule))
if err != nil { if err != nil {
log.Printf("Failed to schedule workflow: %s", err) log.Printf("Failed to schedule workflow: %s", err)
} }