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 {
122
122
httpClient ,
123
123
{
124
124
onTriggerUpdate : ( ) => this . emit ( 'update-requested' ) ,
125
- onTriggerShutdown : ( ) => shutdown ( 'API call' )
125
+ onTriggerShutdown : ( ) => shutdown ( 0 , 'API call' )
126
126
}
127
127
)
128
128
Original file line number Diff line number Diff line change @@ -138,7 +138,9 @@ function manageBackgroundServices(
138
138
}
139
139
140
140
shutdownTimer = setTimeout ( ( ) => {
141
- if ( activeSessions === 0 ) shutdown ( '10 minutes inactive' ) ;
141
+ if ( activeSessions === 0 ) {
142
+ shutdown ( 99 , '10 minutes inactive' ) ;
143
+ }
142
144
} , 1000 * 60 * 10 ) . unref ( ) ;
143
145
}
144
146
} ) ;
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ type ShutdownHandler = () => Promise<unknown>;
5
5
const shutdownHandlers : Array < ShutdownHandler > = [ ] ;
6
6
7
7
export 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' ) ) ;
10
10
}
11
11
12
12
export function addShutdownHandler ( handler : ShutdownHandler ) {
13
13
shutdownHandlers . push ( handler ) ;
14
14
}
15
15
16
- export async function shutdown ( cause : string ) {
16
+ export async function shutdown ( code : number , cause : string ) {
17
17
console . log ( `Shutting down after ${ cause } ...` ) ;
18
18
19
19
const shutdownPromises = Promise . all ( shutdownHandlers . map (
@@ -31,6 +31,6 @@ export async function shutdown(cause: string) {
31
31
delay ( 2000 ) // After 2 seconds, we just close anyway, we're done.
32
32
] ) ;
33
33
34
- process . exit ( 0 ) ;
34
+ process . exit ( code ) ;
35
35
}
36
36
You can’t perform that action at this time.
0 commit comments