Graceful Shutdown (MisskeyIO#156)

---------

Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
This commit is contained in:
riku6460
2023-08-22 21:42:21 +09:00
committed by GitHub
parent eaae8e6bea
commit daf429eb84
5 changed files with 38 additions and 21 deletions

View File

@@ -254,7 +254,7 @@ export class ServerService implements OnApplicationShutdown {
@bindThis
public async dispose(): Promise<void> {
await this.streamingApiServerService.detach();
this.streamingApiServerService.detach();
await this.#fastify.close();
}

View File

@@ -173,13 +173,12 @@ export class StreamingApiServerService {
}
@bindThis
public detach(): Promise<void> {
public detach(): void {
if (this.#cleanConnectionsIntervalId) {
clearInterval(this.#cleanConnectionsIntervalId);
this.#cleanConnectionsIntervalId = null;
}
return new Promise((resolve) => {
this.#wss.close(() => resolve());
});
this.#wss.close();
this.#wss.clients.forEach(client => client.terminate());
}
}