Skip to content

Instantly share code, notes, and snippets.

@ovaillancourt
Created July 12, 2012 15:26
Show Gist options
  • Save ovaillancourt/3098859 to your computer and use it in GitHub Desktop.
Save ovaillancourt/3098859 to your computer and use it in GitHub Desktop.
Run all
#!/usr/bin/env node
var env = require('./env');
var cfg = env.cfg;
var cp = require('child_process');
var fs = require('fs');
var path = require('path');
var processes = [];
//Loop through all the modules that must be executed and run them.
for( var i in cfg.executed ) {
var cur = path.join(cfg.basepath, cfg.executed[i]);
//Extract the entry point for each module to execute.
var pkg = fs.readFileSync(path.join(cur,'package.json'), 'utf8');
var main = JSON.parse(pkg).main;
//Fork process to run entry points.
var proc = cp.fork(path.join(cur, main), [], {
cwd : cur,
env: {
NODE_ENV : process.env.NODE_ENV
}
});
processes.push(proc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment