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');
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user