Skip to content

Instantly share code, notes, and snippets.

@troufster
Created October 15, 2010 07:09
Show Gist options
  • Select an option

  • Save troufster/627756 to your computer and use it in GitHub Desktop.

Select an option

Save troufster/627756 to your computer and use it in GitHub Desktop.
//Expected arguments w. actions
var exargs = {
//help
'-h' : function() { abort(usage); },
//directory where modules reside
'-w' : function(val) {
if (!val) return;
worker.moduleDirs.push(val);
worker.reloadModules();
},
//number of consumer child processes to spawn
'-n' : function(val) {
if (!val) return;
for(var i = 0; i < val;i++) {
var child = spawn('node', ['../lib/consumer.js', i+1]);
child.stdout.on('data', function(data) {
console.log(data.toString());
});
consumers.push(child);
}
}
}
for (var arg in exargs) {
var argindex = args.indexOf(arg);
if(argindex != -1) {
exargs[arg](args[argindex+1]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment