mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
wait for all routes to load before listening
This commit is contained in:
@@ -127,7 +127,6 @@ var middleware;
|
||||
};
|
||||
|
||||
Plugins.reloadRoutes = function (callback) {
|
||||
callback = callback || function () {};
|
||||
var router = express.Router();
|
||||
|
||||
router.hotswapId = 'plugins';
|
||||
@@ -138,7 +137,8 @@ var middleware;
|
||||
var controllers = require('./controllers');
|
||||
Plugins.fireHook('static:app.load', { app: app, router: router, middleware: middleware, controllers: controllers }, function (err) {
|
||||
if (err) {
|
||||
return winston.error('[plugins] Encountered error while executing post-router plugins hooks: ' + err.message);
|
||||
winston.error('[plugins] Encountered error while executing post-router plugins hooks: ' + err.message);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
hotswap.replace('plugins', router);
|
||||
|
||||
@@ -85,7 +85,7 @@ function groupRoutes(app, middleware, controllers) {
|
||||
setupPageRoute(app, '/groups/:slug/members', middleware, middlewares, controllers.groups.members);
|
||||
}
|
||||
|
||||
module.exports = function (app, middleware, hotswapIds) {
|
||||
module.exports = function (app, middleware, hotswapIds, callback) {
|
||||
var routers = [
|
||||
express.Router(), // plugin router
|
||||
express.Router(), // main app router
|
||||
@@ -209,8 +209,9 @@ module.exports = function (app, middleware, hotswapIds) {
|
||||
async.apply(user.addInterstitials),
|
||||
], function (err) {
|
||||
if (err) {
|
||||
return winston.error(err);
|
||||
return callback(err);
|
||||
}
|
||||
winston.info('Routes added');
|
||||
callback();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -96,8 +96,7 @@ function initializeNodeBB(callback) {
|
||||
plugins.fireHook('filter:hotswap.prepare', [], next);
|
||||
},
|
||||
function (hotswapIds, next) {
|
||||
routes(app, middleware, hotswapIds);
|
||||
next();
|
||||
routes(app, middleware, hotswapIds, next);
|
||||
},
|
||||
function (next) {
|
||||
async.series([
|
||||
|
||||
Reference in New Issue
Block a user