File tree Expand file tree Collapse file tree 2 files changed +13
-29
lines changed
Expand file tree Collapse file tree 2 files changed +13
-29
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ import https from 'https';
99
1010import type { RawServerDefault } from 'fastify' ;
1111import CacheableLookup from 'cacheable-lookup' ;
12- import exitHook from 'exit-hook' ;
12+ import { asyncExitHook , gracefulExit } from 'exit-hook' ;
1313import { WebSocket } from 'ws' ;
1414
1515import { logger } from '@app/core/log' ;
@@ -91,17 +91,19 @@ try {
9191 // Start webserver
9292 server = await bootstrapNestServer ( ) ;
9393
94- // On process exit stop HTTP server
95- exitHook ( async ( signal ) => {
96- console . log ( 'exithook' , signal ) ;
97- await server ?. close ?.( ) ;
98- // If port is unix socket, delete socket before exiting
99- unlinkUnixPort ( ) ;
94+ asyncExitHook (
95+ async ( signal ) => {
96+ console . log ( 'exithook' , signal ) ;
97+ await server ?. close ?.( ) ;
98+ // If port is unix socket, delete socket before exiting
99+ unlinkUnixPort ( ) ;
100100
101- shutdownApiEvent ( ) ;
101+ shutdownApiEvent ( ) ;
102102
103- process . exit ( 0 ) ;
104- } ) ;
103+ gracefulExit ( ) ;
104+ } ,
105+ { wait : 9999 }
106+ ) ;
105107 // Start a loop to run the app
106108 await new Promise ( ( ) => { } ) ;
107109} catch ( error : unknown ) {
@@ -115,5 +117,5 @@ try {
115117 }
116118 shutdownApiEvent ( ) ;
117119 // Kill application
118- process . exit ( 1 ) ;
120+ gracefulExit ( 1 ) ;
119121}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments