Skip to content

Node.js based forum software built for the modern web

fix Gruntfile.js to work with bew build step

Julian Lam7a10cffb25d2
diff --git a/Gruntfile.js b/Gruntfile.js
index 73eaad38f4..08baead7a8 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -2,8 +2,9 @@
var fork = require('child_process').fork,
env = process.env,
- worker,
- incomplete = [];
+ worker, updateWorker,
+ incomplete = [],
+ running = 0;
module.exports = function (grunt) {
@@ -19,39 +20,44 @@ module.exports = function (grunt) {
time = Date.now();
if (target === 'lessUpdated_Client') {
- fromFile = ['js', 'tpl', 'acpLess'];
- compiling = 'clientLess';
+ compiling = 'clientCSS';
} else if (target === 'lessUpdated_Admin') {
- fromFile = ['js', 'tpl', 'clientLess'];
- compiling = 'acpLess';
+ compiling = 'acpCSS';
} else if (target === 'clientUpdated') {
- fromFile = ['clientLess', 'acpLess', 'tpl'];
compiling = 'js';
} else if (target === 'templatesUpdated') {
- fromFile = ['js', 'clientLess', 'acpLess'];
compiling = 'tpl';
} else if (target === 'serverUpdated') {
- fromFile = ['clientLess', 'acpLess', 'js', 'tpl'];
+ // Do nothing, just restart
}
- fromFile = fromFile.filter(function (ext) {
- return incomplete.indexOf(ext) === -1;
- });
+ if (incomplete.indexOf(compiling) === -1) {
+ incomplete.push(compiling);
+ }
// @psychobunny, re: #5211, instead of this, just call `node app --build js` or `node app --build css,tpl`
- updateArgs.push('--from-file=' + fromFile.join(','));
- incomplete.push(compiling);
+ updateArgs.push('--build');
+ updateArgs.push(incomplete.join(','));
worker.kill();
- worker = fork('app.js', updateArgs, { env: env });
-
- worker.on('message', function () {
- if (incomplete.length) {
- incomplete = [];
+ if (updateWorker) {
+ updateWorker.kill('SIGKILL');
+ }
+ updateWorker = fork('app.js', updateArgs, { env: env });
+ ++running;
+ updateWorker.on('exit', function () {
+ --running;
+ if (running === 0) {
+ worker = fork('app.js', args, { env: env });
+ worker.on('message', function () {
+ if (incomplete.length) {
+ incomplete = [];
- if (grunt.option('verbose')) {
- grunt.log.writeln('NodeBB restarted in ' + (Date.now() - time) + ' ms');
- }
+ if (grunt.option('verbose')) {
+ grunt.log.writeln('NodeBB restarted in ' + (Date.now() - time) + ' ms');
+ }
+ }
+ });
}
});
}
diff --git a/app.js b/app.js
index 65cc06af30..57ba0e0000 100644
--- a/app.js
+++ b/app.js
@@ -226,6 +226,12 @@ function start() {
// Either way, bad stuff happened. Abort start.
process.exit();
}
+
+ if (process.send) {
+ process.send({
+ action: 'listening'
+ });
+ }
});
}