mirror of
https://github.com/spacebarchat/server.git
synced 2026-06-03 02:14:25 +00:00
Gateway: send reconnect on shutdown
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user