@@ -7,7 +7,7 @@ var childProcess = require('child_process'),
77 LocalBinary = require ( './LocalBinary' ) ,
88 LocalError = require ( './LocalError' ) ,
99 version = require ( '../package.json' ) . version ,
10- psTree = require ( 'ps- tree' ) ;
10+ treeKill = require ( 'tree-kill ' ) ;
1111
1212function Local ( ) {
1313 this . sanitizePath = function ( rawPath ) {
@@ -342,32 +342,7 @@ function Local(){
342342 } ;
343343
344344 this . killAllProcesses = function ( callback ) {
345- psTree ( this . pid , ( err , children ) => {
346- var childPids = children . map ( val => val . PID ) ;
347- var killChecker = setInterval ( ( ) => {
348- if ( childPids . length === 0 ) {
349- clearInterval ( killChecker ) ;
350- try {
351- process . kill ( this . pid ) ;
352- // This gives time to local binary to send kill signal to railsApp.
353- setTimeout ( ( ) => {
354- this . isProcessRunning = false ;
355- callback ( ) ;
356- } , 2000 ) ;
357- } catch ( err ) {
358- this . isProcessRunning = false ;
359- callback ( ) ;
360- }
361- }
362- for ( var i in childPids ) {
363- try {
364- process . kill ( childPids [ i ] ) ;
365- } catch ( err ) {
366- childPids . splice ( i , 1 ) ;
367- }
368- }
369- } , 500 ) ;
370- } ) ;
345+ treeKill ( this . pid , 'SIGTERM' , callback ) ;
371346 } ;
372347}
373348
0 commit comments