diff --git a/src/emitter.js b/src/emitter.js new file mode 100644 index 0000000000..0ce9395048 --- /dev/null +++ b/src/emitter.js @@ -0,0 +1,4 @@ +var events = require('events'), + eventEmitter = new events.EventEmitter(); + +module.exports = eventEmitter; \ No newline at end of file diff --git a/src/middleware/index.js b/src/middleware/index.js index f124832b21..0a97cdfbaf 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -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.'); } }); diff --git a/src/webserver.js b/src/webserver.js index 2197c29fa9..30ecd20f19 100644 --- a/src/webserver.js +++ b/src/webserver.js @@ -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'); + }); }); };