fix(cluster): use for loop instead of _.times

This commit is contained in:
Matteo Pagliazzi
2015-10-12 19:16:47 +02:00
parent f9ab04e4f9
commit 92fc2683c6

View File

@@ -12,7 +12,9 @@ var cores = +nconf.get('WEB_CONCURRENCY') || 0;
if (cores!==0 && cluster.isMaster && (isDev || isProd)) { if (cores!==0 && cluster.isMaster && (isDev || isProd)) {
// Fork workers. If config.json has CORES=x, use that - otherwise, use all cpus-1 (production) // Fork workers. If config.json has CORES=x, use that - otherwise, use all cpus-1 (production)
_.times(cores, cluster.fork); for (var i = 0, n = cores; i < n; i += 1) {
cluster.fork();
}
cluster.on('disconnect', function(worker, code, signal) { cluster.on('disconnect', function(worker, code, signal) {
var w = cluster.fork(); // replace the dead worker var w = cluster.fork(); // replace the dead worker