Skip to content

Commit

Permalink
[api refactor] Remove fork hack since we are now using node-fork
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Jan 6, 2012
1 parent a2c4313 commit 82e2a7d
Showing 1 changed file with 7 additions and 48 deletions.
55 changes: 7 additions & 48 deletions lib/forever/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ Monitor.prototype.trySpawn = function () {
this.spawnWith.cwd = this.cwd || this.spawnWith.cwd;
this.spawnWith.env = this._getEnv();

return this.fork
? this._forkSpawn()
: spawn(this.command, this.args, this.spawnWith);
if (this.fork) {
this.spawnWith.command = this.command;
return fork(this.args[0], this.args.slice(1), this.spawnWith);
}

return spawn(this.command, this.args, this.spawnWith);
};

//
Expand Down Expand Up @@ -393,48 +396,4 @@ Monitor.prototype._getEnv = function () {
});

return merged;
};

//
// ### @private function _forkSpawn()
//
// This is an unfortunate hack which works around two inconsistencies
// in the `child_process` APIs in node.js core as of `v0.6.6`. Pull-requests
// are open to resolve both issues.
//
// https://github.com/joyent/node/pull/2455
// https://github.com/joyent/node/pull/2454
//
// Until then, setup `options.customFds` to always return null.
//
//
Monitor.prototype._forkSpawn = function () {
var execPath = process.execPath,
hackSpawn = {},
self = this,
forked;

if (this.spawnWith && typeof this.spawnWith === 'object') {
Object.keys(this.spawnWith).forEach(function (key) {
hackSpawn[key] = self.spawnWith[key];
});
}

delete hackSpawn.customFds;
Object.defineProperty(hackSpawn, 'customFds', {
get: function () {
return null;
},
set: function () {
//
// Do nothing, ignore the attempt to overwrite here:
// https://github.com/joyent/node/blob/master/lib/child_process.js#L172
//
}
});

process.execPath = this.command;
forked = fork(this.args[0], this.args.slice(1), hackSpawn);
process.execPath = execPath;
return forked;
};
};

0 comments on commit 82e2a7d

Please sign in to comment.