Skip to content

Commit f30a9ba

Browse files
committed
fix when a backgrounded supervisor gets SIGTERM, the sub-proc is not stoped
1 parent f039c1d commit f30a9ba

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/supervisor.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ function run (args) {
6161
executor = (programExt === "coffee") ? "coffee" : "node";
6262
}
6363

64+
// handle case where the supervisor is backgrounded and a SIGTERM is sent
65+
// to it, kill the child. Otherwise the child proc keeps running.
66+
// This does NOT work with SIGKILL.
67+
process.on('SIGTERM', function () {
68+
util.debug("About to exit.");
69+
var child = exports.child;
70+
if (child) {
71+
util.debug("Crashing child...");
72+
process.kill(child.pid);
73+
}
74+
process.exit();
75+
});
76+
6477
util.puts("")
6578
util.debug("Running node-supervisor with");
6679
util.debug(" program '" + program.join(" ") + "'");

0 commit comments

Comments
 (0)