Gateway: send reconnect on shutdown

This commit is contained in:
Rory&
2026-05-26 10:23:42 +02:00
parent 693f58e9eb
commit b924a2ffe5
+11
View File
@@ -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;