Skip to content

feat(shutdown): graceful WebSocket drain on SIGTERM #772

Description

@Ferryx349

Problem

On shutdown, the relay hard-kills all WebSocket clients via webSocket.terminate(). During a rolling deploy, subscribers on the dying instance disconnect abruptly.

HAProxy can retry failed HTTP on another backend, but not in-flight WebSockets. /readyz (#763) handles readiness; WS drain is the missing piece before the HAProxy blue/green overlay.

Proposal

On SIGTERM:

  1. Return 503 on /readyz and stop accepting new connections
  2. Gracefully close existing WebSocket clients (not terminate())
  3. Wait up to WS_DRAIN_TIMEOUT_MS (default 30s), then force-close stragglers
  4. Coordinate shutdown across cluster workers

Ref: https://statusdude.com/blog/zero-downtime-docker-compose

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions