check if mongod is running. show a message.

This commit is contained in:
Gustavo Cortez 2014-01-21 10:09:51 -03:00
parent 99c04752cd
commit 11adc88651
1 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,16 @@ var express = require('express'),
var config = require('./config/config');
//Bootstrap db connection
// If mongod is running
mongoose.connection.on('open', function (ref) {
console.log('Connected to mongo server.');
});
// If mongod is not running
mongoose.connection.on('error', function (err) {
console.log('Could not connect to mongo server!');
console.log(err);
});
mongoose.connect(config.db);
//Bootstrap models