ability to set # of workers to run via config or command line (default = max cpus)

v1.18.x
psychobunny 11 years ago
parent 51eac70f67
commit 32a35164d4

@ -2,11 +2,12 @@
var nconf = require('nconf'), var nconf = require('nconf'),
fs = require('fs'), fs = require('fs'),
path = require('path'),
cluster = require('cluster'), cluster = require('cluster'),
async = require('async'), async = require('async'),
pidFilePath = __dirname + '/pidfile', pidFilePath = __dirname + '/pidfile',
output = fs.openSync(__dirname + '/logs/output.log', 'a'), output = fs.openSync(__dirname + '/logs/output.log', 'a'),
numCPUs = 12,// require('os').cpus().length, numCPUs,
Loader = { Loader = {
timesStarted: 0, timesStarted: 0,
shutdown_queue: [], shutdown_queue: [],
@ -16,6 +17,12 @@ var nconf = require('nconf'),
} }
}; };
nconf.argv().file({
file: path.join(__dirname, '/config.json')
});
numCPUs = nconf.get('cluster') || require('os').cpus().length;
Loader.init = function() { Loader.init = function() {
cluster.setupMaster({ cluster.setupMaster({
exec: "app.js", exec: "app.js",
@ -150,8 +157,6 @@ Loader.reload = function() {
}); });
}; };
nconf.argv();
if (nconf.get('daemon') !== false) { if (nconf.get('daemon') !== false) {
if (fs.existsSync(pidFilePath)) { if (fs.existsSync(pidFilePath)) {
try { try {

Loading…
Cancel
Save