Skip to content

Commit

Permalink
feat(app): add mongodb error handling to quit app if unable to connec…
Browse files Browse the repository at this point in the history
…t with mongodb server for some

reason

when the app will be started with grunt serve, if configured to run with mongodb and the service
will not be available, then the app will initialize anyway but mostly this isnt desired and no
handling or debug information of why the app has no connection to a mongodb server will be
provided
  • Loading branch information
lirantal committed Mar 6, 2015
1 parent 49a3a14 commit 31bee73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/templates/server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ var config = require('./config/environment');
<% if (filters.mongoose) { %>
// Connect to database
mongoose.connect(config.mongo.uri, config.mongo.options);

mongoose.connection.on('error', function(err) {
console.error('MongoDB connection error: ' + err);
process.exit(-1);
}
);
// Populate DB with sample data
if(config.seedDB) { require('./config/seed'); }

Expand Down

0 comments on commit 31bee73

Please sign in to comment.