v1.18.x
barisusakli 8 years ago
parent 8da8e4d8c3
commit 5e0de4b8fb

@ -47,13 +47,8 @@
module.init = function (callback) { module.init = function (callback) {
callback = callback || function () { }; callback = callback || function () { };
var mongoClient;
try { var mongoClient = require('mongodb').MongoClient;
mongoClient = require('mongodb').MongoClient;
} catch (err) {
winston.error('Unable to initialize MongoDB! Is MongoDB installed? Error :' + err.message);
return callback(err);
}
var usernamePassword = ''; var usernamePassword = '';
if (nconf.get('mongo:username') && nconf.get('mongo:password')) { if (nconf.get('mongo:username') && nconf.get('mongo:password')) {
@ -90,7 +85,7 @@
}, },
}; };
connOptions = _.deepExtend((nconf.get('mongo:options') || {}), connOptions); connOptions = _.deepExtend(connOptions, nconf.get('mongo:options') || {});
mongoClient.connect(connString, connOptions, function (err, _db) { mongoClient.connect(connString, connOptions, function (err, _db) {
if (err) { if (err) {
@ -110,10 +105,7 @@
if (nconf.get('mongo:password') && nconf.get('mongo:username')) { if (nconf.get('mongo:password') && nconf.get('mongo:username')) {
db.authenticate(nconf.get('mongo:username'), nconf.get('mongo:password'), function (err) { db.authenticate(nconf.get('mongo:username'), nconf.get('mongo:password'), function (err) {
if (err) { callback(err);
return callback(err);
}
callback();
}); });
} else { } else {
winston.warn('You have no mongo password setup!'); winston.warn('You have no mongo password setup!');

Loading…
Cancel
Save