|
|
|
@ -193,7 +193,32 @@ Workers.initialize = function (Env, config, _cb) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
nThen(function (w) {
|
|
|
|
|
OS.cpus().forEach(function () {
|
|
|
|
|
const max = config.maxWorkers;
|
|
|
|
|
|
|
|
|
|
var limit;
|
|
|
|
|
if (typeof(max) !== 'undefined') {
|
|
|
|
|
// the admin provided a limit on the number of workers
|
|
|
|
|
if (typeof(max) === 'number' && !isNaN(max)) {
|
|
|
|
|
if (max < 1) {
|
|
|
|
|
Log.info("INSUFFICIENT_MAX_WORKERS", max);
|
|
|
|
|
limit = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Log.error("INVALID_MAX_WORKERS", '[' + max + ']');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var logged;
|
|
|
|
|
|
|
|
|
|
OS.cpus().forEach(function (cpu, index) {
|
|
|
|
|
if (limit && index >= limit) {
|
|
|
|
|
if (!logged) {
|
|
|
|
|
logged = true;
|
|
|
|
|
Log.info('WORKER_LIMIT', "(Opting not to use available CPUs beyond " + index + ')');
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initWorker(fork(DB_PATH), w(function (err) {
|
|
|
|
|
if (!err) { return; }
|
|
|
|
|
w.abort();
|
|
|
|
|