File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,7 @@ export class HttpToolkitServerApi extends events.EventEmitter {
122122 httpClient ,
123123 {
124124 onTriggerUpdate : ( ) => this . emit ( 'update-requested' ) ,
125- onTriggerShutdown : ( ) => shutdown ( 'API call' )
125+ onTriggerShutdown : ( ) => shutdown ( 0 , 'API call' )
126126 }
127127 )
128128
Original file line number Diff line number Diff line change @@ -138,7 +138,9 @@ function manageBackgroundServices(
138138 }
139139
140140 shutdownTimer = setTimeout ( ( ) => {
141- if ( activeSessions === 0 ) shutdown ( '10 minutes inactive' ) ;
141+ if ( activeSessions === 0 ) {
142+ shutdown ( 99 , '10 minutes inactive' ) ;
143+ }
142144 } , 1000 * 60 * 10 ) . unref ( ) ;
143145 }
144146 } ) ;
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ type ShutdownHandler = () => Promise<unknown>;
55const shutdownHandlers : Array < ShutdownHandler > = [ ] ;
66
77export function registerShutdownHandler ( ) {
8- process . on ( 'SIGTERM' , ( ) => shutdown ( 'SIGTERM' ) ) ;
9- process . on ( 'SIGINT' , ( ) => shutdown ( 'SIGINT' ) ) ;
8+ process . on ( 'SIGTERM' , ( ) => shutdown ( 0 , 'SIGTERM' ) ) ;
9+ process . on ( 'SIGINT' , ( ) => shutdown ( 0 , 'SIGINT' ) ) ;
1010}
1111
1212export function addShutdownHandler ( handler : ShutdownHandler ) {
1313 shutdownHandlers . push ( handler ) ;
1414}
1515
16- export async function shutdown ( cause : string ) {
16+ export async function shutdown ( code : number , cause : string ) {
1717 console . log ( `Shutting down after ${ cause } ...` ) ;
1818
1919 const shutdownPromises = Promise . all ( shutdownHandlers . map (
@@ -31,6 +31,6 @@ export async function shutdown(cause: string) {
3131 delay ( 2000 ) // After 2 seconds, we just close anyway, we're done.
3232 ] ) ;
3333
34- process . exit ( 0 ) ;
34+ process . exit ( code ) ;
3535}
3636
You can’t perform that action at this time.
0 commit comments