feat: add graceful shutdown for k8s deployments#365
Open
Conversation
Add nova:graceful_shutdown/0 that suspends the ranch listener, drains active connections with a configurable timeout, then stops the listener. Called automatically via prep_stop/1 during application shutdown. Configurable via sys.config: - shutdown_delay: ms to wait before suspending (default 0) - shutdown_drain_timeout: max ms to wait for connections to drain (default 15000) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ranch:info/1 returns a map in ranch 2.x, not a proplist. Match on map keys directly to satisfy dialyzer. Co-Authored-By: Claude Opus 4.6 <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
nova:graceful_shutdown/0public API that handles the full shutdown sequence: delay → suspend listener → drain connections → stop listenerprep_stop/1during application shutdown (SIGTERM)shutdown_delay— ms to wait before suspending (lets k8s remove pod from endpoints, default 0)shutdown_drain_timeout— max ms to wait for in-flight requests to complete (default 15000)Test plan
🤖 Generated with Claude Code