Skip to content

feat: add graceful shutdown for k8s deployments#365

Open
Taure wants to merge 2 commits intomasterfrom
feat/graceful-shutdown
Open

feat: add graceful shutdown for k8s deployments#365
Taure wants to merge 2 commits intomasterfrom
feat/graceful-shutdown

Conversation

@Taure
Copy link
Collaborator

@Taure Taure commented Mar 10, 2026

Summary

  • Add nova:graceful_shutdown/0 public API that handles the full shutdown sequence: delay → suspend listener → drain connections → stop listener
  • Called automatically via prep_stop/1 during application shutdown (SIGTERM)
  • Configurable via sys.config:
    • 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)
  • Logs each shutdown phase with structured metadata

Test plan

  • Compiles cleanly
  • Release builds successfully
  • Heartbeat endpoint responds 200
  • Graceful shutdown logs all phases (delay → suspend → drain → stop)
  • Container stops cleanly on SIGTERM

🤖 Generated with Claude Code

Taure and others added 2 commits March 10, 2026 22:31
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>
Copy link

@kivra-hennys kivra-hennys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

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.

2 participants