Skip to content

Commit

Permalink
Allow multiple modules to be specified on command line
Browse files Browse the repository at this point in the history
  • Loading branch information
clintar committed Mar 31, 2016
1 parent 5c01acc commit f37ac5d
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions init.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,24 @@ var logSystem = 'master';
require('./lib/exceptionWriter.js')(logSystem);


var singleModule = (function(){
var selectedModules = (function(){

var validModules = ['pool', 'api', 'unlocker', 'payments', 'chartsDataCollector'];

for (var i = 0; i < process.argv.length; i++){
if (process.argv[i].indexOf('-module=') === 0){
var moduleName = process.argv[i].split('=')[1];
if (validModules.indexOf(moduleName) > -1)
return moduleName;

log('error', logSystem, 'Invalid module "%s", valid modules: %s', [moduleName, validModules.join(', ')]);
process.exit();
var modulesStr = process.argv[i].split('=')[1];
var moduleNames = modulesStr.split(',');
for(var j = 0; j < moduleNames.length;j++)
{
var module = moduleNames[j];
if (!(validModules.indexOf(module) > -1))
{
log('error', logSystem, 'Invalid module "%s", valid modules: %s', [module, validModules.join(', ')]);
process.exit();
}
return moduleNames;
}
}
}
})();
Expand All @@ -63,25 +69,30 @@ var singleModule = (function(){

checkRedisVersion(function(){

if (singleModule){
log('info', logSystem, 'Running in single module mode: %s', [singleModule]);

switch(singleModule){
case 'pool':
spawnPoolWorkers();
break;
case 'unlocker':
spawnBlockUnlocker();
break;
case 'payments':
spawnPaymentProcessor();
break;
case 'api':
spawnApi();
break;
case 'chartsDataCollector':
spawnChartsDataCollector();
break;
if (selectedModules){
log('info', logSystem, 'Running in selected module mode: %s', [selectedModules]);
for (var i = 0; i < selectedModules.length; i++){
var selectedModule = selectedModules[i];
switch(selectedModule){
case 'pool':
spawnPoolWorkers();
break;
case 'unlocker':
spawnBlockUnlocker();
break;
case 'payments':
spawnPaymentProcessor();
break;
case 'api':
spawnApi();
break;
case 'chartsDataCollector':
spawnChartsDataCollector();
break;
case 'purchases':
spawnPurchaseProcessor();
break;
}
}
}
else{
Expand Down

0 comments on commit f37ac5d

Please sign in to comment.