diff options
| author | Claude Agent <agent@claudomator> | 2026-04-11 18:26:42 +0000 |
|---|---|---|
| committer | Claude Agent <agent@claudomator> | 2026-04-11 18:26:42 +0000 |
| commit | 49cdcd70f275c858b0511a2e88ab30a48b157fa3 (patch) | |
| tree | 79be4e6b12d518be0584c2a8cc03d796471a97f3 /internal/cli/serve.go | |
| parent | e94573bb84874eda7d233cafc36f3a21688c0568 (diff) | |
fix: tie pool submissions to server lifecycle context
Fix 1 (server.go): Replace context.Background() with s.ctx in
handleAnswerQuestion, handleResumeTimedOutTask, and handleRunTask.
Add a ctx field to Server (defaulting to context.Background()) and
a SetContext method so the serve command can wire in the signal-
cancellable lifecycle context.
Fix 2 (serve.go): Call srv.SetContext(ctx) before StartHub so all
pool submissions use the server's root context (already cancelled
on SIGTERM/SIGINT). Pool.Shutdown and its wiring were already present.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/cli/serve.go')
| -rw-r--r-- | internal/cli/serve.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/cli/serve.go b/internal/cli/serve.go index f7493ed..581a064 100644 --- a/internal/cli/serve.go +++ b/internal/cli/serve.go @@ -163,6 +163,11 @@ func serve(addr string) error { "deploy": filepath.Join(wd, "scripts", "deploy"), }) + // Graceful shutdown. + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + srv.SetContext(ctx) srv.StartHub() httpSrv := &http.Server{ @@ -170,10 +175,6 @@ func serve(addr string) error { Handler: srv.Handler(), } - // Graceful shutdown. - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - workerTimeout := 3 * time.Minute if cfg.ShutdownTimeout > 0 { workerTimeout = cfg.ShutdownTimeout |
