The daemon handles SIGINT and SIGTERM itself as well as through fx, and logs a shutdown failure on a clean stop #131

Closed
opened 2026-10-20 01:17:49 +02:00 by clawbot · 1 comment
Collaborator

CLIEntry in internal/routewatch/cli.go registers its own SIGINT and SIGTERM handler with signal.Notify in a start hook and calls shutdowner.Shutdown() from it, on top of fx's own handling of the same signals. GO_HTTP_SERVER_CONVENTIONS.md ("Signal Handling and Graceful Shutdown") says fx owns SIGINT, SIGTERM and the exit code, and no other code calls signal.Notify.

Failure scenario: on docker stop, both fx and this handler see SIGTERM. When fx is already shutting down, the second Shutdown() call returns an error and the daemon logs "Failed to shutdown gracefully" on a clean stop, which reads as a failure in the deploy log. The handler goroutine also outlives the stop.

Found while fixing #100.

Severity: low

Definition of done

  • internal/routewatch/cli.go no longer calls signal.Notify; fx alone handles SIGINT and SIGTERM, as the convention says.
  • A test, failing before the fix, or a check of the built image: a stop signal shuts the daemon down once, logs no "Failed to shutdown gracefully", and the process exits 0.
  • make check passes.

Model: opus-5-5

`CLIEntry` in `internal/routewatch/cli.go` registers its own SIGINT and SIGTERM handler with `signal.Notify` in a start hook and calls `shutdowner.Shutdown()` from it, on top of fx's own handling of the same signals. `GO_HTTP_SERVER_CONVENTIONS.md` ("Signal Handling and Graceful Shutdown") says fx owns SIGINT, SIGTERM and the exit code, and no other code calls `signal.Notify`. Failure scenario: on `docker stop`, both fx and this handler see SIGTERM. When fx is already shutting down, the second `Shutdown()` call returns an error and the daemon logs "Failed to shutdown gracefully" on a clean stop, which reads as a failure in the deploy log. The handler goroutine also outlives the stop. Found while fixing https://git.eeqj.de/sneak/routewatch/issues/100. Severity: low ## Definition of done - `internal/routewatch/cli.go` no longer calls `signal.Notify`; fx alone handles SIGINT and SIGTERM, as the convention says. - A test, failing before the fix, or a check of the built image: a stop signal shuts the daemon down once, logs no "Failed to shutdown gracefully", and the process exits 0. - `make check` passes. Model: opus-5-5
clawbot self-assigned this 2026-10-20 01:17:49 +02:00
Author
Collaborator

#135 removes the start hook's own SIGINT and SIGTERM handler, so fx alone handles both. The failure line this issue describes does not show up on a clean stop with fx v1.24.0; the PR body says why and how the change was checked instead.

Model: opus-5-5

https://git.eeqj.de/sneak/routewatch/pulls/135 removes the start hook's own SIGINT and SIGTERM handler, so fx alone handles both. The failure line this issue describes does not show up on a clean stop with fx v1.24.0; the PR body says why and how the change was checked instead. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#131