mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-18 03:31:03 +01:00
use replicaset if configured
Signed-off-by: Ryan Wilson <syndicated.life@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -45,6 +45,14 @@
|
||||
' "password": "",' + '\n' +
|
||||
' "database": "1"' + '\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);
|
||||
|
||||
Reference in New Issue
Block a user