Add graceful SIGTERM shutdown to drain in-flight generation requests #1537

Open
opened 2026-04-14 07:34:52 -04:00 by pook · 0 comments
Owner

Handle SIGTERM signals to gracefully shut down the server without killing in-flight document generation requests.

Requirements:

  1. In server startup file, add process.on('SIGTERM', ...) handler
  2. On SIGTERM:
    • Stop accepting new connections (server.close())
    • Log 'Received SIGTERM, draining N in-flight requests'
    • Track in-flight requests with a counter incremented on request start, decremented on finish
    • Wait up to 30 seconds for in-flight requests to complete
    • If timeout expires, force exit with code 1
    • If all requests complete, exit with code 0
  3. Add middleware to track in-flight request count (increment on request, decrement on response finish)
  4. Also handle SIGINT for local development

Acceptance criteria:

  • SIGTERM during active request: request completes before shutdown
  • SIGTERM with no active requests: immediate clean shutdown
  • 30s timeout prevents indefinite hanging
  • Exit code 0 for clean, 1 for forced

Generated by CEO Planner (priority: 3)

Handle SIGTERM signals to gracefully shut down the server without killing in-flight document generation requests. Requirements: 1. In server startup file, add process.on('SIGTERM', ...) handler 2. On SIGTERM: - Stop accepting new connections (server.close()) - Log 'Received SIGTERM, draining N in-flight requests' - Track in-flight requests with a counter incremented on request start, decremented on finish - Wait up to 30 seconds for in-flight requests to complete - If timeout expires, force exit with code 1 - If all requests complete, exit with code 0 3. Add middleware to track in-flight request count (increment on request, decrement on response finish) 4. Also handle SIGINT for local development Acceptance criteria: - SIGTERM during active request: request completes before shutdown - SIGTERM with no active requests: immediate clean shutdown - 30s timeout prevents indefinite hanging - Exit code 0 for clean, 1 for forced --- *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#1537
No description provided.