feat: improve graceful shutdown with configurable timeout#23
Open
bianbiandashen wants to merge 1 commit into
Open
feat: improve graceful shutdown with configurable timeout#23bianbiandashen wants to merge 1 commit into
bianbiandashen wants to merge 1 commit into
Conversation
Enhance the graceful shutdown mechanism with better logging and a configurable timeout setting. Changes: - Add shutdown_timeout_secs to [server] config (default: 30 seconds) - Improve shutdown logging to show which signal was received - Log the configured timeout when shutdown begins - Change final log message to indicate graceful completion The shutdown flow now: 1. Receives SIGTERM or SIGINT (Ctrl+C) 2. Logs which signal was received 3. Stops accepting new connections 4. Logs the timeout and waits for in-flight requests 5. Completes when all requests finish (or timeout expires) 6. Removes PID file and logs graceful completion Configuration example: ```toml [server] shutdown_timeout_secs = 30 # Wait up to 30s for requests to complete ``` This is important for Kubernetes deployments where pods receive SIGTERM during rolling updates and need time to drain connections.
ADD-SP
reviewed
Feb 15, 2026
| /// requests to complete before forcefully terminating. | ||
| /// Default: 30 seconds. | ||
| #[serde(default = "default_shutdown_timeout_secs")] | ||
| pub shutdown_timeout_secs: u64, |
Collaborator
There was a problem hiding this comment.
Would it make sense to use std::time::Duration here?
ADD-SP
force-pushed
the
main
branch
2 times, most recently
from
April 12, 2026 17:00
798e737 to
87955a4
Compare
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
Enhance the graceful shutdown mechanism with better logging and a configurable timeout setting.
Problem
The current shutdown implementation:
In Kubernetes deployments, pods receive SIGTERM during rolling updates and need predictable drain behavior.
Solution
Configurable Shutdown Timeout
Add
shutdown_timeout_secsto the[server]config section:Default: 30 seconds
Improved Logging
The shutdown flow now logs:
Example output:
Shutdown Behavior
Changes
src/config.rs: Addshutdown_timeout_secstoServerConfigsrc/main.rs: Improve shutdown signal handling and loggingclawshell.example.toml: Document new configuration optionTest Plan