Graceful shutdown and error handling for the web server #161

Closed
opened 2026-10-07 11:51:52 +00:00 by aniram · 0 comments
Owner

http.ListenAndServe(connStr, mainMux) currently ignores its returned error and has no timeouts, so a port conflict exits silently and slow clients can hold connections open.

Use an explicit http.Server with ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout.
Handle SIGINT/SIGTERM via signal.NotifyContext and call Shutdown with a deadline.
Return the error from run() and exit non-zero on failure.

Acceptance criteria:

  • Starting the server on an occupied port prints an error and exits with code 1.
  • SIGTERM lets in-flight requests finish.
http.ListenAndServe(connStr, mainMux) currently ignores its returned error and has no timeouts, so a port conflict exits silently and slow clients can hold connections open. Use an explicit http.Server with ReadHeaderTimeout, ReadTimeout, WriteTimeout and IdleTimeout. Handle SIGINT/SIGTERM via signal.NotifyContext and call Shutdown with a deadline. Return the error from run() and exit non-zero on failure. Acceptance criteria: - Starting the server on an occupied port prints an error and exits with code 1. - **SIGTERM lets in-flight requests finish.**
aniram added this to the 2027.1 milestone 2026-10-07 11:51:52 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
overdrives/chambersbr#161
No description provided.