mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
closed #2179
This commit is contained in:
5
app.js
5
app.js
@@ -168,6 +168,11 @@ function start() {
|
||||
meta.js.map = message.map;
|
||||
winston.info('[cluster] Client-side javascript and mapping propagated to worker ' + cluster.worker.id);
|
||||
break;
|
||||
case 'css-propagate':
|
||||
meta.css.cache = message.cache;
|
||||
meta.css.acpCache = message.acpCache;
|
||||
winston.info('[cluster] Stylesheet propagated to worker ' + cluster.worker.id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
27
loader.js
27
loader.js
@@ -14,6 +14,10 @@ var nconf = require('nconf'),
|
||||
js: {
|
||||
cache: undefined,
|
||||
map: undefined
|
||||
},
|
||||
css: {
|
||||
cache: undefined,
|
||||
acpCache: undefined
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,6 +40,14 @@ Loader.init = function() {
|
||||
});
|
||||
}
|
||||
|
||||
if (Loader.css.cache) {
|
||||
worker.send({
|
||||
action: 'css-propagate',
|
||||
cache: Loader.css.cache,
|
||||
acpCache: Loader.css.acpCache
|
||||
});
|
||||
}
|
||||
|
||||
worker.send('bind');
|
||||
|
||||
// Kill an instance in the shutdown queue
|
||||
@@ -69,6 +81,21 @@ Loader.init = function() {
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'css-propagate':
|
||||
Loader.css.cache = message.cache;
|
||||
Loader.css.acpCache = message.acpCache;
|
||||
|
||||
var otherWorkers = Object.keys(cluster.workers).filter(function(worker_id) {
|
||||
return parseInt(worker_id, 10) !== parseInt(worker.id, 10);
|
||||
});
|
||||
otherWorkers.forEach(function(worker_id) {
|
||||
cluster.workers[worker_id].send({
|
||||
action: 'css-propagate',
|
||||
cache: message.cache,
|
||||
acpCache: message.acpCache
|
||||
});
|
||||
});
|
||||
break;
|
||||
case 'listening':
|
||||
if (message.primary) {
|
||||
Loader.primaryWorker = parseInt(worker.id, 10);
|
||||
|
||||
@@ -24,6 +24,7 @@ module.exports = function(Meta) {
|
||||
Meta.css.defaultBranding = {};
|
||||
|
||||
Meta.css.minify = function(callback) {
|
||||
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
||||
winston.info('[meta/css] Minifying LESS/CSS');
|
||||
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
|
||||
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
|
||||
@@ -63,8 +64,26 @@ module.exports = function(Meta) {
|
||||
function(next) {
|
||||
minify(acpSource, paths, 'acpCache', next);
|
||||
}
|
||||
], callback);
|
||||
], function(err, minified) {
|
||||
// Propagate to other workers
|
||||
if (cluster.isWorker) {
|
||||
process.send({
|
||||
action: 'css-propagate',
|
||||
cache: minified[0],
|
||||
acpCache: minified[1]
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Meta.css.commitToFile = function(filename) {
|
||||
@@ -123,7 +142,7 @@ module.exports = function(Meta) {
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
callback(null, css);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user