Change startup and only run indexing while not in test env
parent
d18940a9dd
commit
9208619803
27
app.js
27
app.js
|
@ -323,7 +323,7 @@ app.on('uncaughtException', (err) => {
|
|||
process.exit(2);
|
||||
});
|
||||
|
||||
initDb(config.databaseConnectionString, (err, db) => {
|
||||
initDb(config.databaseConnectionString, async (err, db) => {
|
||||
// On connection error we display then exit
|
||||
if(err){
|
||||
console.log(colors.red('Error connecting to MongoDB: ' + err));
|
||||
|
@ -354,19 +354,24 @@ initDb(config.databaseConnectionString, (err, db) => {
|
|||
config.trackStock = true;
|
||||
}
|
||||
|
||||
// run indexing
|
||||
common.runIndexing(app)
|
||||
.then(app.listen(app.get('port')))
|
||||
.then(() => {
|
||||
// lift the app
|
||||
// We index when not in test env
|
||||
if(process.env.NODE_ENV !== 'test'){
|
||||
try{
|
||||
await common.runIndexing(app);
|
||||
}catch(ex){
|
||||
console.error(colors.red('Error setting up indexes:' + err));
|
||||
}
|
||||
}
|
||||
|
||||
// Start the app
|
||||
try{
|
||||
await app.listen(app.get('port'));
|
||||
app.emit('appStarted');
|
||||
console.log(colors.green('expressCart running on host: http://localhost:' + app.get('port')));
|
||||
return;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(colors.red('Error setting up indexes:' + err));
|
||||
}catch(ex){
|
||||
console.error(colors.red('Error starting expressCart app:' + err));
|
||||
process.exit(2);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = app;
|
||||
|
|
Loading…
Reference in New Issue