use replicaset if configured

Signed-off-by: Ryan Wilson <syndicated.life@gmail.com>
v1.18.x
Ryan Wilson 10 years ago
parent 17dfb4df94
commit ec6c618751

@ -73,7 +73,16 @@
nconf.set('mongo:database', '0'); 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 = { var connOptions = {
server: { server: {
poolSize: parseInt(nconf.get('mongo:poolSize'), 10) || 10 poolSize: parseInt(nconf.get('mongo:poolSize'), 10) || 10

@ -45,6 +45,14 @@
' "password": "",' + '\n' + ' "password": "",' + '\n' +
' "database": "1"' + '\n' + ' "database": "1"' + '\n' +
'}\n'+ '}\n'+
' or (mongo) in a replicaset' + '\n' +
'"test_database": {' + '\n' +
' "host": "127.0.0.1,127.0.0.1,127.0.0.1",' + '\n' +
' "port": "27017,27018,27019",' + '\n' +
' "username": "",' + '\n' +
' "password": "",' + '\n' +
' "database": "nodebb_test"' + '\n' +
'}\n'+
'===========================================================' '==========================================================='
); );
winston.error(errorText); winston.error(errorText);

Loading…
Cancel
Save