Skip to content

Commit

Permalink
fix: nodemon reporting crash
Browse files Browse the repository at this point in the history
Fixes #1173
  • Loading branch information
remy committed Dec 16, 2017
1 parent bd9d595 commit 4fb1fb3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
20 changes: 13 additions & 7 deletions lib/monitor/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,21 @@ function kill(child, signal, callback) {
// an array of PIDs that have spawned under nodemon, and we send each the
// configured signal (default: SIGUSR2) signal, which fixes #335
// note that psTree also works if `ps` is missing by looking in /proc
const sig = signal.replace('SIG', '');
psTree(child.pid, function (err, kids) {
// make sure we kill from smallest to largest
const pids = kids.map(p => p.PID).concat(child.pid).sort();

pids.forEach(pid => {
exec('kill -' + signals[signal] + ' ' + pid, () => {});
});
callback();
if (psTree.hasPS) {
spawn('kill', ['-s', sig, child.pid].concat(kids.map(p => p.PID)))
.on('close', callback);
} else {
// make sure we kill from smallest to largest
const pids = kids.map(p => p.PID).concat(child.pid).sort();
pids.forEach(pid => {
exec('kill -' + signals[signal] + ' ' + pid, () => { });
});
callback();
}
});

}
}

Expand Down
6 changes: 3 additions & 3 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 @@ -52,7 +52,7 @@
"should": "~4.0.0"
},
"dependencies": {
"@remy/pstree": "^1.0.1",
"@remy/pstree": "^1.1.0",
"chokidar": "^1.7.0",
"debug": "^2.6.8",
"es6-promise": "^3.3.1",
Expand Down

0 comments on commit 4fb1fb3

Please sign in to comment.