Skip to content

fix: stop the HTTP server before the background services on shutdown - #57

Merged
flthibaud merged 2 commits into
developfrom
fix/shutdown-order
Nov 11, 2026
Merged

flthibaud merged 2 commits into
developfrom
fix/shutdown-order

Conversation

@flthibaud

Copy link
Copy Markdown
Owner

On SIGTERM the scheduler and the subscription and OPML services were stopped first, and the HTTP server only afterwards. Requests arriving in between started background work on a context that was already cancelled: a new subscription's import failed at once and counted a failure against a healthy feed, and wg.Go could run after wg.Wait.

  • srv.Shutdown now runs first; its error is kept and sent once the services have stopped. The 20-second budget is unchanged.

No new test: the change is a reorder inside the signal goroutine. go vet and go test -race ./cmd/api pass.

Closes #40

@flthibaud

Copy link
Copy Markdown
Owner Author

Review: OK to merge.

  • ListenAndServe returns as soon as Shutdown is called and serve() then waits on shutdownError, which is now sent after the services have stopped, so the process still exits only once everything is down.
  • Not covered by a test; not exercised with a real SIGTERM either.

@flthibaud
flthibaud merged commit 4437550 into develop Nov 11, 2026
5 checks passed
@flthibaud
flthibaud deleted the fix/shutdown-order branch November 11, 2026 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shutdown stops background services before the HTTP server

1 participant