added emitter class; express.listen only after background tasks complete; closes #1227

v1.18.x
psychobunny 11 years ago
parent 16f1db4f5d
commit 941c3b2d7e

@ -0,0 +1,4 @@
var events = require('events'),
eventEmitter = new events.EventEmitter();
module.exports = eventEmitter;

@ -7,6 +7,8 @@ var templates = require('./../../public/src/templates'),
plugins = require('./../plugins'),
db = require('./../database'),
auth = require('./../routes/authentication'),
emitter = require('./../emitter'),
async = require('async'),
path = require('path'),
fs = require('fs'),
@ -119,6 +121,7 @@ function compileTemplates(pluginTemplates) {
if (err) {
winston.error(err);
} else {
emitter.emit('templates:compiled');
winston.info('[themes] Successfully compiled templates.');
}
});

@ -14,7 +14,8 @@ var path = require('path'),
meta = require('./meta'),
logger = require('./logger'),
middleware = require('./middleware'),
routes = require('./routes');
routes = require('./routes'),
emitter = require('./emitter');
if(nconf.get('ssl')) {
server = require('https').createServer({
@ -92,9 +93,11 @@ if(nconf.get('ssl')) {
}
});
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');
emitter.on('templates:compiled', function() {
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');
});
});
};

Loading…
Cancel
Save