@@ -33,6 +33,7 @@ var Monitor = exports.Monitor = function (script, options) {
33
33
options = options || { } ;
34
34
this . silent = options . silent || false ;
35
35
this . forever = options . forever || false ;
36
+ this . killTree = options . killTree !== false ;
36
37
this . uid = options . uid || forever . randomString ( 24 ) ;
37
38
this . pidFile = options . pidFile || path . join ( forever . config . get ( 'pidPath' ) , this . uid + '.pid' ) ;
38
39
this . max = options . max ;
@@ -373,13 +374,20 @@ Monitor.prototype.kill = function (forceStop) {
373
374
if ( forceStop ) {
374
375
this . forceStop = true ;
375
376
}
376
- psTree ( this . child . pid , function ( err , children ) {
377
- var pids = children . map ( function ( p ) { return p . PID } )
378
- pids . shift ( self . child . pid )
379
- spawn ( 'kill' , [ '-9' ] . concat ( pids ) ) . on ( 'exit' , function ( ) {
380
- self . emit ( 'stop' , self . childData ) ;
381
- } )
382
- } )
377
+
378
+ if ( this . killTree ) {
379
+ psTree ( this . child . pid , function ( err , children ) {
380
+ var pids = children . map ( function ( p ) { return p . PID } )
381
+ pids . shift ( self . child . pid )
382
+ spawn ( 'kill' , [ '-9' ] . concat ( pids ) ) . on ( 'exit' , function ( ) {
383
+ self . emit ( 'stop' , self . childData ) ;
384
+ } )
385
+ } ) ;
386
+ }
387
+ else {
388
+ this . child . kill ( ) ;
389
+ this . emit ( 'stop' , this . childData ) ;
390
+ }
383
391
384
392
}
385
393
0 commit comments