Skip to content

Node.js based forum software built for the modern web

Fix restarted secondary instances waiting forever for the templates:compiled message. Fix update notification always appearing when an instance restarts even if there was no update. Closes #4870 (#4871)

Ben Lubarb08696515fdd
diff --git a/loader.js b/loader.js
index e853fa562c..52e441bb9a 100644
--- a/loader.js
+++ b/loader.js
@@ -29,7 +29,8 @@ var pidFilePath = __dirname + '/pidfile',
css: {
cache: undefined,
acpCache: undefined
- }
+ },
+ templatesCompiled: false
};
Loader.init = function(callback) {
@@ -112,6 +113,12 @@ Loader.addWorkerEvents = function(worker) {
});
}
+ if (Loader.templatesCompiled && !worker.isPrimary) {
+ worker.send({
+ action: 'templates:compiled'
+ });
+ }
+
break;
case 'restart':
@@ -141,6 +148,8 @@ Loader.addWorkerEvents = function(worker) {
}, worker.pid);
break;
case 'templates:compiled':
+ Loader.templatesCompiled = true;
+
Loader.notifyWorkers({
action: 'templates:compiled',
}, worker.pid);
diff --git a/public/src/app.js b/public/src/app.js
index 65038d343e..8875bd2d64 100644
--- a/public/src/app.js
+++ b/public/src/app.js
@@ -56,8 +56,8 @@ app.cacheBuster = null;
socket.removeAllListeners('event:nodebb.ready');
socket.on('event:nodebb.ready', function(data) {
- if (!app.cacheBusters || app.cacheBusters['cache-buster'] !== data['cache-buster']) {
- app.cacheBusters = data;
+ if (!app.cacheBuster || app.cacheBuster !== data['cache-buster']) {
+ app.cacheBuster = data['cache-buster'];
app.alert({
alert_id: 'forum_updated',