Exit with status 1 when the web server cannot listen (closes #73) #78

Merged
clawbot merged 1 commits from issue-73-fail-on-listen-error into next 2026-10-14 18:26:05 +02:00
Collaborator

Fixes #73.

Server.Start opened its port inside a goroutine and returned nil at once, so a port already in use was only logged and the daemon kept streaming and writing the database with no web server. It now opens the listener before it returns and returns that error; serving then runs in the background on the open listener. CLIEntry turns an error from Run into an fx shutdown with exit status 1, so the process ends after the normal stop sequence and a container restart policy can act.

What the diff does not show:

  • Run reaches Start after the streamer has started; the normal stop sequence stops it, and skips the parts that never started.
  • fx keeps a shutdown request made before it starts waiting for one, so an error that arrives while fx is still starting also ends the process.
  • Only an error from Run stops the daemon, not a nil return: Run waits on the context fx hands to start hooks, which ends after fx's start timeout while the daemon keeps running.
  • The test holds the port on all interfaces, because on some systems a listen on all interfaces succeeds next to a listener bound only to 127.0.0.1.
  • A serving error after a successful listen is still only logged, as before.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/routewatch/issues/73. `Server.Start` opened its port inside a goroutine and returned nil at once, so a port already in use was only logged and the daemon kept streaming and writing the database with no web server. It now opens the listener before it returns and returns that error; serving then runs in the background on the open listener. `CLIEntry` turns an error from `Run` into an fx shutdown with exit status 1, so the process ends after the normal stop sequence and a container restart policy can act. What the diff does not show: - `Run` reaches `Start` after the streamer has started; the normal stop sequence stops it, and skips the parts that never started. - fx keeps a shutdown request made before it starts waiting for one, so an error that arrives while fx is still starting also ends the process. - Only an error from `Run` stops the daemon, not a nil return: `Run` waits on the context fx hands to start hooks, which ends after fx's start timeout while the daemon keeps running. - The test holds the port on all interfaces, because on some systems a listen on all interfaces succeeds next to a listener bound only to 127.0.0.1. - A serving error after a successful listen is still only logged, as before. Model: opus-5-5
clawbot added the needs-review label 2026-10-14 15:30:23 +02:00
clawbot self-assigned this 2026-10-14 15:30:23 +02:00
Author
Collaborator
  • TODO.md: the PR adds a Completed Steps line for this fix. The plan on record for this round (#72 (comment)) is that fix PRs leave TODO.md alone and #72 adds one line per closed issue, so that the PRs in flight do not conflict on its first lines. The line is out of scope and lands where other fix branches add theirs. Acceptable: this PR without the TODO.md change.

Model: opus-5-5

- `TODO.md`: the PR adds a Completed Steps line for this fix. The plan on record for this round (https://git.eeqj.de/sneak/routewatch/issues/72#issuecomment-139587) is that fix PRs leave `TODO.md` alone and https://git.eeqj.de/sneak/routewatch/issues/72 adds one line per closed issue, so that the PRs in flight do not conflict on its first lines. The line is out of scope and lands where other fix branches add theirs. Acceptable: this PR without the `TODO.md` change. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-14 16:37:10 +02:00
clawbot added 1 commit 2026-10-14 16:44:36 +02:00
Server.Start now opens its listener before it returns, so a port that is
already in use comes back as an error instead of being logged from a
goroutine while the daemon keeps streaming with no web server. CLIEntry
turns any error from Run into a shutdown with exit status 1, so a
container restart policy can act on it.

Model: opus-5-5
clawbot force-pushed issue-73-fail-on-listen-error from 278b9e658c to 515bc1e5a2 2026-10-14 16:44:36 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-14 17:02:55 +02:00
Author
Collaborator
  • TODO.md: the Completed Steps line is removed; the PR no longer touches TODO.md.

Model: opus-5-5

- `TODO.md`: the Completed Steps line is removed; the PR no longer touches `TODO.md`. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit b4dee48401 into next 2026-10-14 18:26:05 +02:00
clawbot deleted branch issue-73-fail-on-listen-error 2026-10-14 18:26:05 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/routewatch#78