From eec5b8f9c885d33c9310fbec3f1388d8125db11a Mon Sep 17 00:00:00 2001 From: Mir Arif Hasan Date: Tue, 12 Dec 2023 12:38:07 +0600 Subject: [PATCH] chore: app shutdown way changed --- packages/hoppscotch-backend/src/infra-config/helper.ts | 2 +- packages/hoppscotch-backend/src/main.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-backend/src/infra-config/helper.ts b/packages/hoppscotch-backend/src/infra-config/helper.ts index f9c4d66ef..e053d767e 100644 --- a/packages/hoppscotch-backend/src/infra-config/helper.ts +++ b/packages/hoppscotch-backend/src/infra-config/helper.ts @@ -39,6 +39,6 @@ export function stopApp() { setTimeout(() => { console.log('Stopping app now...'); - process.exit(); + process.kill(process.pid, 'SIGTERM'); }, 5000); } diff --git a/packages/hoppscotch-backend/src/main.ts b/packages/hoppscotch-backend/src/main.ts index d0afbcc77..dae82a3a0 100644 --- a/packages/hoppscotch-backend/src/main.ts +++ b/packages/hoppscotch-backend/src/main.ts @@ -53,6 +53,12 @@ async function bootstrap() { }); app.use(cookieParser()); await app.listen(configService.get('PORT') || 3170); + + // Graceful shutdown + process.on('SIGTERM', async () => { + console.info('SIGTERM signal received'); + await app.close(); + }); } if (!process.env.GENERATE_GQL_SCHEMA) {