Skip to content

Exit non-zero when a server fails to start - #418

Merged
folbricht merged 2 commits into
masterfrom
fix-server-exit-code
Sep 3, 2026
Merged

folbricht merged 2 commits into
masterfrom
fix-server-exit-code

Conversation

@folbricht

Copy link
Copy Markdown
Owner

The chunk and index servers printed the error from ListenAndServe to stderr and then returned nil, so a server that never came up exited with status 0. desync chunk-server -s store -l 127.0.0.1:1 reported bind: permission denied and exited 0, which supervisors and CI read as a clean shutdown.

The error is now handed back to the caller so cobra reports it and the process exits 1. Shutting down because the context was cancelled, which is what a signal does, still returns nil.

The chunk and index servers printed the error from ListenAndServe to
stderr and then returned nil, so a server that never came up exited with
status 0. Supervisors and CI read that as a clean shutdown.

Hand the error back to the caller instead, and keep returning nil when
the context is cancelled, which is how a signal shuts the server down.
The derived context only existed to merge the two ways serve() can
finish. A select on the error channel and the caller's context does that
directly, so the context, its cancel and the second, non-blocking select
all go.
@folbricht
folbricht merged commit d9973b7 into master Sep 3, 2026
9 checks passed
@folbricht
folbricht deleted the fix-server-exit-code branch September 3, 2026 10:07
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.

1 participant

⌂ 换网址