Permalink
Browse files

Added cluster support. Fixes #27

  • Loading branch information...
fgnass committed Feb 7, 2012
1 parent 5bac2d9 commit a4d461ebfa7a50325d361f27184aa75bfa9f4ca9
Showing with 9 additions and 1 deletion.
  1. +6 −1 node-dev
  2. +3 −0 wrapper.js
View
@@ -1,6 +1,11 @@
#! /usr/bin/env node
var spawn = require('child_process').spawn;
+var env = process.env;
var node = process.argv[0];
+
+/* Pass the location of the node-dev script to the child process */
+env.NODE_DEV = process.argv[1];
+
var args = process.argv.slice(2);
if (!args.length) {
@@ -19,7 +24,7 @@ for (var i=0; i < args.length; i++) {
function start() {
var child = spawn(node, args, {
cwd: process.cwd(),
- env: process.env,
+ env: env,
customFds: [0, 1, 2]
});
child.on('exit', function(code) {
View
@@ -10,6 +10,9 @@ var spawn = require('child_process').spawn;
/** Remove wrapper.js from the argv array */
process.argv.splice(1, 1);
+/** Set the execPath so that forked child processes will also uses node-dev */
+process.argv[0] = process.execPath = process.env.NODE_DEV;
+
/** Resolve the location of the main script relative to cwd */
var main = Path.resolve(process.cwd(), process.argv[1]);

0 comments on commit a4d461e

Please sign in to comment.