Skip to content

feat: Reuse existing function to implement graceful shutdown logic - #564

Open
Dilnawaz-khan-ops wants to merge 1 commit into
jpillora:masterfrom
OutSystems:graceful-shutdown
Open

feat: Reuse existing function to implement graceful shutdown logic#564
Dilnawaz-khan-ops wants to merge 1 commit into
jpillora:masterfrom
OutSystems:graceful-shutdown

Conversation

@Dilnawaz-khan-ops

@Dilnawaz-khan-ops Dilnawaz-khan-ops commented Jul 16, 2025

Copy link
Copy Markdown

Summary

Improves signal handling by reusing the existing InterruptContext() function and extending it to handle SIGTERM. This is useful for containers like ECS Fargate which terminate using SIGTERM.

Changes Introduced.

  • Listens for syscall.SIGTERM in addition to os.Interrupt
  • Logs signal received and when graceful shutdown is complete

Why 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.

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>
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.

1 participant