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 1dcaa9f5f9
commit ac7a178f88
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 () => { process.on("SIGTERM", async () => {
console.log("Shutting down due to SIGTERM"); console.log("Shutting down due to SIGTERM");
await gateway.stop();
await cdn.stop();
await api.stop();
server.close(); server.close();
Sentry.close(); Sentry.close();
}); });

View File

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