feat: Reuse existing function to implement graceful shutdown logic - #564
Open
Dilnawaz-khan-ops wants to merge 1 commit into
Open
feat: Reuse existing function to implement graceful shutdown logic#564Dilnawaz-khan-ops wants to merge 1 commit into
Dilnawaz-khan-ops wants to merge 1 commit into
Conversation
jpillora
added a commit
that referenced
this pull request
Jul 16, 2026
- InterruptContext also catches SIGTERM (docker stop, kubernetes) and registers the handler before returning, closing the startup window where SIGTERM took the default kill path; a second signal forces immediate exit - GoServe context cancellation now runs http.Server.Shutdown with a grace period (SHUTDOWN_GRACE, default 5s) draining in-flight requests before force-closing; hijacked websocket tunnels are unaffected and close with their owners - drop dead listenErr field; explicit Server.Close() (tests, chserver.Close) stays immediate - supersedes PR #564 (same SIGTERM idea, minus its premature "shutdown complete" logging) - tests: SIGTERM cancels the context (unix), in-flight request drains during shutdown while new conns are refused Closes md task 18 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Improves signal handling by reusing the existing
InterruptContext()function and extending it to handleSIGTERM. This is useful for containers like ECS Fargate which terminate usingSIGTERM.Changes Introduced.
syscall.SIGTERMin addition toos.InterruptWhy This Matters
Without this, containers might be force-killed before completing cleanup logic. This update ensures the app exits gracefully when the platform sends a termination signal.