File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed
Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " wds" ,
3- "version" : " 0.22 .0" ,
3+ "version" : " 0.23 .0" ,
44 "author" : " Harry Brundage" ,
55 "license" : " MIT" ,
66 "bin" : {
Original file line number Diff line number Diff line change @@ -61,8 +61,8 @@ export class Project {
6161 this . supervisor . restart ( ) ;
6262 }
6363
64- async shutdown ( code = 0 ) {
65- await this . supervisor . stop ( ) ;
64+ async shutdown ( code : number , signal : NodeJS . Signals = "SIGTERM" ) {
65+ await this . supervisor . stop ( signal ) ;
6666 for ( const cleanup of this . cleanups ) {
6767 cleanup ( ) ;
6868 }
Original file line number Diff line number Diff line change @@ -14,11 +14,11 @@ export class Supervisor extends EventEmitter {
1414 }
1515
1616 /**
17- * Stop the process with a graceful SIGTERM , then SIGKILL after a timeout
17+ * Stop the process with a given signal , then SIGKILL after a timeout
1818 * Kills the whole process group so that any subprocesses of the process are also killed
1919 * See https://azimi.me/2014/12/31/kill-child_process-node-js.html for more information
2020 */
21- async stop ( ) {
21+ async stop ( signal : NodeJS . Signals = "SIGTERM" ) {
2222 // if we never started the child process, we don't need to do anything
2323 if ( ! this . process || ! this . process . pid ) return ;
2424
@@ -27,15 +27,15 @@ export class Supervisor extends EventEmitter {
2727
2828 const ref = this . process ;
2929 const exit = once ( ref , "exit" ) ;
30- this . kill ( "SIGTERM" ) ;
30+ this . kill ( signal ) ;
3131
3232 await Promise . race ( [ exit , setTimeout ( 5000 ) ] ) ;
3333 if ( ! ref . killed ) {
3434 this . kill ( "SIGKILL" , ref . pid ) ;
3535 }
3636 }
3737
38- kill ( signal = "SIGKILL" , pid = this . process ?. pid ) {
38+ kill ( signal : NodeJS . Signals = "SIGKILL" , pid = this . process ?. pid ) {
3939 if ( pid ) {
4040 try {
4141 process . kill ( - pid , signal ) ;
Original file line number Diff line number Diff line change @@ -197,11 +197,11 @@ export const wds = async (options: RunOptions) => {
197197
198198 process . on ( "SIGINT" , ( ) => {
199199 log . debug ( `process ${ process . pid } got SIGINT` ) ;
200- void project . shutdown ( 0 ) ;
200+ void project . shutdown ( 0 , "SIGINT" ) ;
201201 } ) ;
202202 process . on ( "SIGTERM" , ( ) => {
203203 log . debug ( `process ${ process . pid } got SIGTERM` ) ;
204- void project . shutdown ( 0 ) ;
204+ void project . shutdown ( 0 , "SIGTERM" ) ;
205205 } ) ;
206206
207207 project . supervisor . process . on ( "exit" , ( code , signal ) => {
You can’t perform that action at this time.
0 commit comments