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