Add graceful shutdown handler for SIGTERM/SIGINT #911

Open
opened 2026-04-12 03:13:06 -04:00 by pook · 0 comments
Owner

Add a graceful shutdown handler to the Express server for production deployment readiness. Required by #908 (Dockerfile).

Implementation:

  1. Create a shutdown() function that: logs 'Shutting down...', calls server.close() to stop accepting new connections, closes the database connection pool (pool.end()), then calls process.exit(0).
  2. Add a 10-second force-exit timeout: setTimeout(() => process.exit(1), 10000) in case connections don't drain.
  3. Register process.on('SIGTERM', shutdown) and process.on('SIGINT', shutdown).

Without this, Docker container restarts will leak database connections and may cause pool exhaustion under load.

Acceptance: Sending SIGTERM to the running server triggers logged shutdown sequence, closes DB pool, exits with code 0 within 10 seconds.


Generated by CEO Planner (priority: 3)

Add a graceful shutdown handler to the Express server for production deployment readiness. Required by #908 (Dockerfile). Implementation: 1. Create a shutdown() function that: logs 'Shutting down...', calls server.close() to stop accepting new connections, closes the database connection pool (pool.end()), then calls process.exit(0). 2. Add a 10-second force-exit timeout: setTimeout(() => process.exit(1), 10000) in case connections don't drain. 3. Register process.on('SIGTERM', shutdown) and process.on('SIGINT', shutdown). Without this, Docker container restarts will leak database connections and may cause pool exhaustion under load. Acceptance: Sending SIGTERM to the running server triggers logged shutdown sequence, closes DB pool, exits with code 0 within 10 seconds. --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#911
No description provided.