File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -161,8 +161,27 @@ class StartCommand extends Command {
161161 // check start status
162162 yield this . checkStatus ( argv ) ;
163163 } else {
164- // signal event had been handler at common-bin helper
165- this . helper . spawn ( 'node' , eggArgs , options ) ;
164+ options . stdio = options . stdio || 'inherit' ;
165+ this . logger . debug ( 'Run spawn `node %s`' , eggArgs . join ( ' ' ) ) ;
166+ const child = this . child = spawn ( 'node' , eggArgs , options ) ;
167+ child . once ( 'exit' , code => {
168+ if ( code !== 0 ) {
169+ child . emit ( 'error' , new Error ( `spawn node ${ eggArgs . join ( ' ' ) } fail, exit code: ${ code } ` ) ) ;
170+ }
171+ } ) ;
172+
173+ // attach master signal to child
174+ let signal ;
175+ [ 'SIGINT' , 'SIGQUIT' , 'SIGTERM' ] . forEach ( event => {
176+ process . once ( event , ( ) => {
177+ signal = event ;
178+ process . exit ( 0 ) ;
179+ } ) ;
180+ } ) ;
181+ process . once ( 'exit' , ( ) => {
182+ this . logger . debug ( 'Kill child %s with %s' , child . pid , signal ) ;
183+ child . kill ( signal ) ;
184+ } ) ;
166185 }
167186 }
168187
You can’t perform that action at this time.
0 commit comments