v1.18.x
Julian Lam 11 years ago
parent d95398f808
commit 5b38c3b9ee

@ -122,7 +122,8 @@ function start() {
webserver = require('./src/webserver'), webserver = require('./src/webserver'),
sockets = require('./src/socket.io'), sockets = require('./src/socket.io'),
plugins = require('./src/plugins'), plugins = require('./src/plugins'),
upgrade = require('./src/upgrade'); upgrade = require('./src/upgrade')
meta = require('./src/meta');
templates.setGlobal('relative_path', nconf.get('relative_path')); templates.setGlobal('relative_path', nconf.get('relative_path'));
@ -142,6 +143,10 @@ function start() {
process.on('SIGTERM', shutdown); process.on('SIGTERM', shutdown);
process.on('SIGINT', shutdown); process.on('SIGINT', shutdown);
process.on('SIGHUP', restart); process.on('SIGHUP', restart);
process.on('uncaughtException', function() {
meta.js.killMinifier();
shutdown();
})
} else { } else {
winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:'); winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
winston.warn(' node app --upgrade'); winston.warn(' node app --upgrade');
@ -281,7 +286,7 @@ function shutdown(code) {
winston.info('[app] Database connection closed.'); winston.info('[app] Database connection closed.');
winston.info('[app] Shutdown complete.'); winston.info('[app] Shutdown complete.');
process.exit(); process.exit(1);
} }
function restart() { function restart() {

@ -8,8 +8,7 @@ var nconf = require('nconf'),
nbb_start = function() { nbb_start = function() {
if (timesStarted > 3) { if (timesStarted > 3) {
console.log('\n[loader] Experienced three start attempts in 10 seconds, most likely am error on startup. Halting.'); console.log('\n[loader] Experienced three start attempts in 10 seconds, most likely am error on startup. Halting.');
process.exit(); return nbb_stop();
return;
} }
timesStarted++; timesStarted++;
@ -54,7 +53,7 @@ var nconf = require('nconf'),
} }
}, },
nbb_restart = function() { nbb_restart = function() {
nbb.on('exit', function() { nbb.removeAllListeners('exit').on('exit', function() {
nbb_start(); nbb_start();
}); });
nbb.kill(); nbb.kill();

@ -296,7 +296,7 @@ var fs = require('fs'),
}, },
minify: function(minify) { minify: function(minify) {
// Prepare js for minification/concatenation // Prepare js for minification/concatenation
var minifier = fork('minifier.js'); var minifier = this.minifierProc = fork('minifier.js');
minifier.on('message', function(payload) { minifier.on('message', function(payload) {
if (payload.action !== 'error') { if (payload.action !== 'error') {
@ -317,6 +317,11 @@ var fs = require('fs'),
scripts: Meta.js.scripts scripts: Meta.js.scripts
}); });
}); });
},
killMinifier: function(callback) {
if (this.minifierProc) {
this.minifierProc.kill('SIGTERM');
}
} }
}; };

Loading…
Cancel
Save