fix: use context.Background() in TriggerRun so job outlives HTTP request

r.Context() is cancelled when the HTTP handler returns (after 201 is sent),
causing the job to be immediately marked as cancelled_shutdown before WoL
even runs. Use context.Background() so the job goroutine runs independently
of the HTTP request lifecycle.
This commit is contained in:
2026-07-09 00:04:44 -04:00
parent 48d8fff5df
commit 7a024cec3b
+2 -1
View File
@@ -1,6 +1,7 @@
package api
import (
"context"
"database/sql"
"encoding/json"
"fmt"
@@ -160,7 +161,7 @@ func (h *JobHandler) TriggerRun(w http.ResponseWriter, r *http.Request) {
slog.Error("job run goroutine panicked", "job_id", jobID, "panic", r)
}
}()
h.engine.Run(r.Context(), jobID, pairID)
h.engine.Run(context.Background(), jobID, pairID)
}()
jobRepo := models.NewJobRepository(h.db)