use replicaset if configured

Signed-off-by: Ryan Wilson <syndicated.life@gmail.com>
This commit is contained in:
Ryan Wilson
2015-04-25 08:05:33 -07:00
parent 17dfb4df94
commit ec6c618751
2 changed files with 18 additions and 1 deletions

View File

@@ -73,7 +73,16 @@
nconf.set('mongo:database', '0');
}
var connString = 'mongodb://' + usernamePassword + nconf.get('mongo:host') + ':' + nconf.get('mongo:port') + '/' + nconf.get('mongo:database');
var hosts = nconf.get('mongo:host').split(',');
var ports = nconf.get('mongo:port').split(',');
var servers = [];
for (var i = 0; i < hosts.length; i++) {
servers.push(hosts[i] + ':' + ports[i]);
}
var connString = 'mongodb://' + usernamePassword + servers.join() + '/' + nconf.get('mongo:database');
var connOptions = {
server: {
poolSize: parseInt(nconf.get('mongo:poolSize'), 10) || 10