mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 01:26:12 +02:00
refactor: send single message
This commit is contained in:
@@ -173,9 +173,10 @@ module.exports = function (grunt) {
|
|||||||
winston.error(err.stack);
|
winston.error(err.stack);
|
||||||
}
|
}
|
||||||
if (worker) {
|
if (worker) {
|
||||||
worker.send({ compiling: compiling });
|
worker.send({
|
||||||
// Send livereload event via Socket.IO for instant browser refresh
|
compiling: compiling,
|
||||||
worker.send({ livereload: true });
|
livereload: true, // Send livereload event via Socket.IO for instant browser refresh
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
30
src/start.js
30
src/start.js
@@ -107,20 +107,24 @@ function addProcessHandlers() {
|
|||||||
shutdown(1);
|
shutdown(1);
|
||||||
});
|
});
|
||||||
process.on('message', (msg) => {
|
process.on('message', (msg) => {
|
||||||
if (msg && Array.isArray(msg.compiling)) {
|
if (msg) {
|
||||||
if (msg.compiling.includes('tpl')) {
|
if (Array.isArray(msg.compiling)) {
|
||||||
const benchpressjs = require('benchpressjs');
|
if (msg.compiling.includes('tpl')) {
|
||||||
benchpressjs.flush();
|
const benchpressjs = require('benchpressjs');
|
||||||
} else if (msg.compiling.includes('lang')) {
|
benchpressjs.flush();
|
||||||
const translator = require('./translator');
|
} else if (msg.compiling.includes('lang')) {
|
||||||
translator.flush();
|
const translator = require('./translator');
|
||||||
|
translator.flush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (msg && msg.livereload) {
|
|
||||||
// Send livereload event to all connected clients via Socket.IO
|
if (msg.livereload) {
|
||||||
const websockets = require('./socket.io');
|
// Send livereload event to all connected clients via Socket.IO
|
||||||
if (websockets.server) {
|
const websockets = require('./socket.io');
|
||||||
websockets.server.emit('event:livereload');
|
if (websockets.server) {
|
||||||
winston.info('[livereload] Sent reload event to all clients');
|
websockets.server.emit('event:livereload');
|
||||||
|
winston.info('[livereload] Sent reload event to all clients');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user