From aca9d9011ab59c85397c8b80ba07a2570ff70366 Mon Sep 17 00:00:00 2001 From: anna Date: Wed, 28 Jul 2021 10:36:30 +0800 Subject: [PATCH 1/2] Anonymous function point is the same value, so all the job params will be Covered. so, when restart the containers, all the schedules will be called, but used the same params --- backend/go-app/main.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/go-app/main.go b/backend/go-app/main.go index 55c5d705..cc0cf04f 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -3970,15 +3970,10 @@ func runInitEs(ctx context.Context) { log.Printf("[WARNING] Failed getting schedules during service init: %s", err) } else { 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) - job := func() { + url := &url.URL{} + job := func(schedule ScheduleOld) func() { + return func() { //log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds) //log.Printf("ARG: %s", schedule.WrappedArgument) @@ -3993,9 +3988,18 @@ func runInitEs(ctx context.Context) { 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) - jobret, err := newscheduler.Every(schedule.Seconds).Seconds().NotImmediately().Run(job) + jobret, err := newscheduler.Every(schedule.Seconds).Seconds().NotImmediately().Run(job(schedule)) if err != nil { log.Printf("Failed to schedule workflow: %s", err) } From 08dc1559f5c5fe1fd7289c47903eea4474813e1c Mon Sep 17 00:00:00 2001 From: frikky Date: Fri, 30 Jul 2021 20:07:48 +0200 Subject: [PATCH 2/2] Fixed minor issue with #450 --- backend/go-app/go.mod | 2 +- backend/go-app/main.go | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 8fd1bd75..60670e20 100644 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -2,7 +2,7 @@ module shuffle go 1.13 -//replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared +replace github.com/frikky/shuffle-shared => ../../../../git/shuffle-shared //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi diff --git a/backend/go-app/main.go b/backend/go-app/main.go index c5b9b863..9c0d1f68 100644 --- a/backend/go-app/main.go +++ b/backend/go-app/main.go @@ -3975,10 +3975,9 @@ func runInitEs(ctx context.Context) { log.Printf("[INFO] Setting up %d schedule(s)", len(schedules)) url := &url.URL{} - job := func(schedule ScheduleOld) func() { + job := func(schedule shuffle.ScheduleOld) func() { return func() { - //log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds) - //log.Printf("ARG: %s", schedule.WrappedArgument) + log.Printf("[INFO] Running schedule %s with interval %d.", schedule.Id, schedule.Seconds) request := &http.Request{ URL: url, @@ -4000,7 +3999,6 @@ func runInitEs(ctx context.Context) { } //log.Printf("Schedule: %#v", schedule) - //log.Printf("Schedule time: every %d seconds", schedule.Seconds) jobret, err := newscheduler.Every(schedule.Seconds).Seconds().NotImmediately().Run(job(schedule)) if err != nil {