Reworked startup sequence to respect server.listen() failures and timings.

v1.18.x
Micheil Smith 11 years ago
parent 83b22a357c
commit 8cd1005a03

@ -84,8 +84,7 @@ function start() {
nconf.set('base_dir', __dirname); nconf.set('base_dir', __dirname);
winston.info('Time: ' + new Date()); winston.info('Time: ' + new Date());
winston.info('Initializing NodeBB v' + pkg.version + ', on port ' + nconf.get('port') + ', using ' + nconf.get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.'); winston.info('Initializing NodeBB v' + pkg.version + ', using ' + nconf./**/get('database') +' store at ' + nconf.get(nconf.get('database') + ':host') + ':' + nconf.get(nconf.get('database') + ':port') + '.');
winston.info('NodeBB instance bound to: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? 'Any address (0.0.0.0)' : nconf.get('bind_address')));
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
winston.info('Base Configuration OK.'); winston.info('Base Configuration OK.');

@ -415,8 +415,20 @@ module.exports.server = server;
templates.logout = parsedTemplate; templates.logout = parsedTemplate;
}); });
winston.info('NodeBB Ready'); server.on("error", function(e){
server.listen(nconf.get('PORT') || nconf.get('port'), nconf.get('bind_address')); if (e.code === 'EADDRINUSE') {
winston.error('NodeBB address in use, exiting...');
process.exit(1);
} else {
throw e;
}
});
var port = nconf.get('PORT') || nconf.get('port');
winston.info('NodeBB attempting to listen on: ' + ((nconf.get('bind_address') === "0.0.0.0" || !nconf.get('bind_address')) ? '0.0.0.0' : nconf.get('bind_address')) + ':' + port);
server.listen(port, nconf.get('bind_address'), function(){
winston.info('NodeBB Ready');
});
}; };
app.create_route = function (url, tpl) { // to remove app.create_route = function (url, tpl) { // to remove

Loading…
Cancel
Save