diff --git a/bin/fork-shim b/bin/fork-shim new file mode 100644 index 00000000..3ca31b8b --- /dev/null +++ b/bin/fork-shim @@ -0,0 +1,5 @@ +#!/usr/bin/env node +var spawn = require('child_process').spawn; +spawn(process.argv[2], process.argv.slice(3), { + customFds: [0, 1, 2] +}); diff --git a/lib/forever/monitor.js b/lib/forever/monitor.js index 7707cfac..6c021fee 100644 --- a/lib/forever/monitor.js +++ b/lib/forever/monitor.js @@ -9,9 +9,9 @@ var events = require('events'), fs = require('fs'), path = require('path'), - nodeFork = require('node-fork'), - fork = nodeFork.fork, - spawn = require('child_process').spawn, + child_process = require('child_process'), + fork = child_process.fork, + spawn = child_process.spawn, broadway = require('broadway'), psTree = require('ps-tree'), winston = require('winston'), @@ -75,7 +75,6 @@ var Monitor = exports.Monitor = function (script, options) { this.spawnWith = options.spawnWith || {}; this.sourceDir = options.sourceDir; this.fork = options.fork || false; - this.forkShim = options.forkShim || false; this.cwd = options.cwd || null; this.hideEnv = options.hideEnv || []; this._env = options.env || {}; @@ -216,17 +215,10 @@ Monitor.prototype.trySpawn = function () { if (this.fork) { this.spawnWith.silent = true; - this.spawnWith.command = this.command; - - if (this.forkShim) { - if (typeof this.forkShim === 'string') { - this.spawnWith.forkModule = this.forkShim; - } - this.spawnWith.env['FORK_SHIM'] = true; - return nodeFork.shim.fork(this.args[0], this.args.slice(1), this.spawnWith); - } - - return fork(this.args[0], this.args.slice(1), this.spawnWith); + return fork( + path.join(__dirname, '..', '..', 'bin', 'fork-shim'), + [this.command].concat(this.args), this.spawnWith + ); } return spawn(this.command, this.args, this.spawnWith);