summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-05-26 10:23:42 +0200
committerRory& <root@rory.gay>2026-05-28 09:12:25 +0200
commitb924a2ffe5b806c0fc6fcbcbe602a560d3296bd8 (patch)
treefac6fb6a24f0d54cadadf7ec1330173b32a617fc
parentFix some copyright headers (diff)
downloadserver-ts-b924a2ffe5b806c0fc6fcbcbe602a560d3296bd8.tar.xz
Gateway: send reconnect on shutdown
-rw-r--r--src/gateway/events/Connection.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gateway/events/Connection.ts b/src/gateway/events/Connection.ts

index 5876c3e1..6f67c0c5 100644 --- a/src/gateway/events/Connection.ts +++ b/src/gateway/events/Connection.ts
@@ -43,6 +43,17 @@ export async function Connection(this: WS.Server, socket: WebSocket, request: In if (index !== -1) openConnections.splice(index, 1); }); + for (const sig of ["SIGINT", "SIGTERM", "SIGQUIT"] as const) { + process.on(sig, async () => { + await Send(socket, { + op: OPCODES.Reconnect, + s: socket.sequence++, + d: Math.round(Math.random() * 5000), + }); + socket.close(1000); + }); + } + const forwardedFor = Config.get().security.forwardedFor; const ipAddress = forwardedFor ? (request.headers[forwardedFor.toLowerCase()] as string) : request.socket.remoteAddress;