Files
orca/cloud/apps/relay
Neil b14e705093 fix(relay): exit promptly on SIGTERM instead of waiting out docker's stop timeout (#37443)
* fix(relay): exit promptly on SIGTERM instead of waiting out docker's stop timeout

On SIGTERM the relay drained sessions and called server.close(), which waits
for every open socket. A TCP connection that never sends a byte (or sends
partial headers) is not idle, and server.close() also stops the header-timeout
checks, so nothing ever closed it. The process stayed alive until docker's
--stop-timeout 300 SIGKILLed it: about five minutes of every cell VM
replacement during a same-cap roll.

Shutdown now tracks accepted sockets (including upgraded WebSockets), keeps
the existing drain order, destroys sockets still open after a 5 s grace, waits
(bounded) for queued pool clients, closes the database and exits 0. An unref'd
10 s backstop exits even if the database close hangs. SIGTERM/SIGINT use
process.on behind a shutting-down guard so a repeated signal no longer kills
the process with 143.

The new blackbox test fails on the previous index.ts (silent TCP and
partial-headers peers keep it alive past the test bound) and passes now.

* style(relay): satisfy changed-lines lint gate in SIGTERM exit change
2026-11-02 13:47:54 -08:00
..