cleaned up loader.js

v1.18.x
barisusakli 10 years ago
parent 83a679fc15
commit e49dfc7266

@ -1,4 +1,4 @@
"use strict"; 'use strict';
var nconf = require('nconf'), var nconf = require('nconf'),
net = require('net'), net = require('net'),
@ -13,7 +13,7 @@ var nconf = require('nconf'),
pidFilePath = __dirname + '/pidfile', pidFilePath = __dirname + '/pidfile',
output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }), output = logrotate({ file: __dirname + '/logs/output.log', size: '1m', keep: 3, compress: true }),
silent = process.env.NODE_ENV !== 'development' ? true : false, silent = process.env.NODE_ENV !== 'development',
numProcs, numProcs,
handles = {}, handles = {},
handleIndex = 0, handleIndex = 0,
@ -101,36 +101,24 @@ Loader.addClusterEvents = function(callback) {
Loader.js.map = message.map; Loader.js.map = message.map;
Loader.js.hash = message.hash; Loader.js.hash = message.hash;
otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) { Loader.notifyWorkers({
return parseInt(worker_id, 10) !== parseInt(worker.id, 10); action: 'js-propagate',
}); cache: message.cache,
map: message.map,
otherWorkers.forEach(function(worker_id) { hash: message.hash
cluster.workers[worker_id].send({ }, worker.id);
action: 'js-propagate',
cache: message.cache,
map: message.map,
hash: message.hash
});
});
break; break;
case 'css-propagate': case 'css-propagate':
Loader.css.cache = message.cache; Loader.css.cache = message.cache;
Loader.css.acpCache = message.acpCache; Loader.css.acpCache = message.acpCache;
Loader.css.hash = message.hash; Loader.css.hash = message.hash;
otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) { Loader.notifyWorkers({
return parseInt(worker_id, 10) !== parseInt(worker.id, 10); action: 'css-propagate',
}); cache: message.cache,
acpCache: message.acpCache,
otherWorkers.forEach(function(worker_id) { hash: message.hash
cluster.workers[worker_id].send({ }, worker.id);
action: 'css-propagate',
cache: message.cache,
acpCache: message.acpCache,
hash: message.hash
});
});
break; break;
case 'listening': case 'listening':
if (message.primary) { if (message.primary) {
@ -307,13 +295,15 @@ function closeHandles() {
} }
} }
Loader.notifyWorkers = function (msg) { Loader.notifyWorkers = function (msg, worker_id) {
worker_id = parseInt(worker_id, 10);
Object.keys(cluster.workers).forEach(function(id) { Object.keys(cluster.workers).forEach(function(id) {
cluster.workers[id].send(msg); if (parseInt(id, 10) !== worker_id) {
cluster.workers[id].send(msg);
}
}); });
}; };
nconf.argv().file({ nconf.argv().file({
file: path.join(__dirname, '/config.json') file: path.join(__dirname, '/config.json')
}); });

Loading…
Cancel
Save