Skip to content

Commit 3518fe0

Browse files
committed
Merge pull request #877 from lirantal/feat-mongodb-error-handle
feat(app): exit process if unable to connect to mongo
2 parents 49a3a14 + 31bee73 commit 3518fe0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/templates/server/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ var config = require('./config/environment');
1313
<% if (filters.mongoose) { %>
1414
// Connect to database
1515
mongoose.connect(config.mongo.uri, config.mongo.options);
16-
16+
mongoose.connection.on('error', function(err) {
17+
console.error('MongoDB connection error: ' + err);
18+
process.exit(-1);
19+
}
20+
);
1721
// Populate DB with sample data
1822
if(config.seedDB) { require('./config/seed'); }
1923

0 commit comments

Comments
 (0)