Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions lib/Local.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var childProcess = require('child_process'),
LocalBinary = require('./LocalBinary'),
LocalError = require('./LocalError'),
version = require('../package.json').version,
psTree = require('ps-tree');
treeKill = require('tree-kill');

function Local(){
this.sanitizePath = function(rawPath) {
Expand Down Expand Up @@ -342,32 +342,7 @@ function Local(){
};

this.killAllProcesses = function(callback){
psTree(this.pid, (err, children) => {
var childPids = children.map(val => val.PID);
var killChecker = setInterval(() => {
if(childPids.length === 0) {
clearInterval(killChecker);
try {
process.kill(this.pid);
// This gives time to local binary to send kill signal to railsApp.
setTimeout(() => {
this.isProcessRunning = false;
callback();
}, 2000);
} catch(err) {
this.isProcessRunning = false;
callback();
}
}
for(var i in childPids) {
try {
process.kill(childPids[i]);
} catch(err) {
childPids.splice(i, 1);
}
}
},500);
});
treeKill(this.pid, 'SIGTERM', callback);
};
}

Expand Down
156 changes: 14 additions & 142 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"agent-base": "^6.0.2",
"https-proxy-agent": "^5.0.1",
"is-running": "^2.1.0",
"ps-tree": "=1.2.0"
"tree-kill": "^1.2.2"
},
"devDependencies": {
"eslint": "^7.0.0",
Expand Down