From a306f37dfe31132cc23b08b632c60c4ee4e68bc0 Mon Sep 17 00:00:00 2001 From: FruitRiin Date: Thu, 17 Aug 2023 23:55:36 +0900 Subject: [PATCH] =?UTF-8?q?graceful=20shutdown=20=E3=81=A7=E3=81=8D?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/package.json | 1 + packages/backend/src/server/ServerService.ts | 3 ++- packages/backend/src/server/api/StreamingApiServerService.ts | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/backend/package.json b/packages/backend/package.json index 8c5b67ced64c..151aba74feb9 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -216,6 +216,7 @@ "eslint": "8.46.0", "eslint-plugin-import": "2.28.0", "execa": "7.2.0", + "fastify-graceful-shutdown": "^3.5.1", "jest": "29.6.2", "jest-mock": "29.6.2", "simple-oauth2": "5.0.0" diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index b40eeb31b174..b223561aee9f 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -31,7 +31,7 @@ import { FileServerService } from './FileServerService.js'; import { ClientServerService } from './web/ClientServerService.js'; import { OpenApiServerService } from './api/openapi/OpenApiServerService.js'; import { OAuth2ProviderService } from './oauth/OAuth2ProviderService.js'; - +import fasitfyGracefulShutdown from "fastify-graceful-shutdown" const _dirname = fileURLToPath(new URL('.', import.meta.url)); @Injectable() @@ -100,6 +100,7 @@ export class ServerService implements OnApplicationShutdown { fastify.register(this.nodeinfoServerService.createServer); fastify.register(this.wellKnownServerService.createServer); fastify.register(this.oauth2ProviderService.createServer); + fastify.register(fasitfyGracefulShutdown) fastify.get<{ Params: { path: string }; Querystring: { static?: any; badge?: any; }; }>('/emoji/:path(.*)', async (request, reply) => { const path = request.params.path; diff --git a/packages/backend/src/server/api/StreamingApiServerService.ts b/packages/backend/src/server/api/StreamingApiServerService.ts index 74c469143587..aa9102b3c176 100644 --- a/packages/backend/src/server/api/StreamingApiServerService.ts +++ b/packages/backend/src/server/api/StreamingApiServerService.ts @@ -19,6 +19,7 @@ import MainStreamConnection from './stream/index.js'; import { ChannelsService } from './stream/ChannelsService.js'; import type * as http from 'node:http'; + @Injectable() export class StreamingApiServerService { #wss: WebSocket.WebSocketServer;