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) {