1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-05 10:22:31 +01:00

Fix SIGTERM handler not disconnecting gateway clients and leaving timeouts active

This commit is contained in:
Madeline 2023-01-26 14:29:33 +11:00
parent b82c6d672b
commit 45793e82fd
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
2 changed files with 9 additions and 2 deletions

View File

@ -39,6 +39,9 @@ const gateway = new Gateway.Server({ server, port, production });
process.on("SIGTERM", async () => {
console.log("Shutting down due to SIGTERM");
await gateway.stop();
await cdn.stop();
await api.stop();
server.close();
Sentry.close();
});

View File

@ -82,7 +82,11 @@ export class Server {
}
async stop() {
closeDatabase();
this.server.close();
this.ws.clients.forEach((x) => x.close());
this.ws.close(() => {
this.server.close(() => {
closeDatabase();
});
});
}
}