diff --git a/functions/onprem/worker/worker.go b/functions/onprem/worker/worker.go index 190694fd..63fe3d19 100644 --- a/functions/onprem/worker/worker.go +++ b/functions/onprem/worker/worker.go @@ -3828,6 +3828,12 @@ func handleRunExecution(resp http.ResponseWriter, request *http.Request) { resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err))) return } + + // Checks if a workflow is done 30 seconds later, and sends info to backend no matter what + go func() { + time.Sleep(time.Duration(30) * time.Second) + checkUnfinished(resp, request, execRequest) + }() ctx := context.Background() // FIXME: This should be PER EXECUTION @@ -3925,12 +3931,6 @@ func handleRunExecution(resp http.ResponseWriter, request *http.Request) { log.Printf("[ERROR] Failed initializing execution saving for %s: %s", workflowExecution.ExecutionId, err) } - // Checks if a workflow is done 30 seconds later, and sends info to backend no matter what - go func() { - time.Sleep(time.Duration(30) * time.Second) - checkUnfinished(resp, request, execRequest) - }() - if workflowExecution.Status == "FINISHED" || workflowExecution.Status == "SUCCESS" { log.Printf("[DEBUG] Workflow %s is finished. Exiting worker.", workflowExecution.ExecutionId) log.Printf("[DEBUG] Shutting down (20)")