Open lautaroalvarez opened 2 years ago
In app.js add two new functions: beforeInit and afterInit
app.js
beforeInit
afterInit
They should be async functions because we want to wait it before continue.
Then, in the bin/init.js add this two functions in the "wake-up flow":
bin/init.js
Should be something like this:
return app.connectMongoose() .then(() => { application = app.initialize(); return app.beforeInit(); }) .then(() => { application.listen(process.env.SERVER_PORT); logger.info(`Your server is listening on port ${process.env.SERVER_PORT}`); app.afterInit(); }) .catch((error) => { logger.error('APP STOPPED'); logger.error(error.stack); return process.exit(1); });
The scheduleRunner(); and createDefaultAdmin(); should be inside the afterInit function.
scheduleRunner();
createDefaultAdmin();
In tests we have to call this new functions. Its something like this:
function start() { return connectMongoose() .then(() => { return app.beforeInit(); }) .then(() => { return app.initialize(); }); }
In
app.js
add two new functions:beforeInit
andafterInit
They should be async functions because we want to wait it before continue.
Then, in the
bin/init.js
add this two functions in the "wake-up flow":Should be something like this:
The
scheduleRunner();
andcreateDefaultAdmin();
should be inside the afterInit function.Tests
In tests we have to call this new functions. Its something like this: