Browse files

[api] Expose `Monitor.killTree` for killing process trees for process…

…es spawned by forever
  • Loading branch information...
1 parent a83a1e1 commit 4e27e3d0742256fc95c6721003984db34d29099e @indexzero committed Oct 8, 2011
Showing with 17 additions and 9 deletions.
  1. +15 −7 lib/forever/monitor.js
  2. +2 −2 package.json
View
22 lib/forever/monitor.js
@@ -33,6 +33,7 @@ var Monitor = exports.Monitor = function (script, options) {
options = options || {};
this.silent = options.silent || false;
this.forever = options.forever || false;
+ this.killTree = options.killTree !== false;
this.uid = options.uid || forever.randomString(24);
this.pidFile = options.pidFile || path.join(forever.config.get('pidPath'), this.uid + '.pid');
this.max = options.max;
@@ -373,13 +374,20 @@ Monitor.prototype.kill = function (forceStop) {
if (forceStop) {
this.forceStop = true;
}
- psTree(this.child.pid, function (err, children) {
- var pids = children.map(function (p) { return p.PID })
- pids.shift(self.child.pid)
- spawn('kill', ['-9'].concat(pids)).on('exit', function () {
- self.emit('stop', self.childData);
- })
- })
+
+ if (this.killTree) {
+ psTree(this.child.pid, function (err, children) {
+ var pids = children.map(function (p) { return p.PID })
+ pids.shift(self.child.pid)
+ spawn('kill', ['-9'].concat(pids)).on('exit', function () {
+ self.emit('stop', self.childData);
+ })
+ });
+ }
+ else {
+ this.child.kill();
+ this.emit('stop', this.childData);
+ }
}
View
4 package.json
@@ -32,15 +32,15 @@
"dnode": "0.8.x",
"eyes": "0.1.x",
"daemon": "0.3.x",
+ "minimatch": "0.0.x",
"mkdirp": "0.x.x",
"nconf": "0.x.x",
"optimist": "0.2.x",
"pkginfo": "0.x.x",
"portfinder": "0.x.x",
+ "ps-tree": "0.0.x",
"timespan": "2.0.x",
"watch": "0.3.x",
- "minimatch": "0.0.x",
- "ps-tree": "0.0.x",
"winston": "0.5.x"
},
"devDependencies": {

0 comments on commit 4e27e3d

Please sign in to comment.