mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
hide secondary_database option behind "advanced" setup flag
This commit is contained in:
@@ -1,14 +1,35 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
var nconf = require('nconf'),
|
var nconf = require('nconf'),
|
||||||
databaseType = nconf.get('database'),
|
primaryDBConfig = nconf.get('database'),
|
||||||
winston = require('winston');
|
secondaryDBConfig = nconf.get('secondary_database'),
|
||||||
|
secondaryModules = nconf.get('secondary_db_modules'),
|
||||||
|
winston = require('winston'),
|
||||||
|
|
||||||
if(!databaseType) {
|
ALLOWED_MODULES = ['hash', 'list', 'sets', 'sorted'];
|
||||||
|
|
||||||
|
if(!primaryDBConfig) {
|
||||||
winston.info('Database type not set! Run node app --setup');
|
winston.info('Database type not set! Run node app --setup');
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = require('./database/' + databaseType);
|
function setupSecondaryDB() {
|
||||||
|
var secondaryDB = require('./database/' + secondaryDBConfig);
|
||||||
|
|
||||||
module.exports = db;
|
secondaryModules = secondaryModules.split(/,\s*/);
|
||||||
|
|
||||||
|
for (var module in secondaryModules) {
|
||||||
|
if (secondaryModules.hasOwnProperty(module) && ALLOWED_MODULES.indexOf(module) !== -1) {
|
||||||
|
primaryDB[module] = secondaryDB[module];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var primaryDB = require('./database/' + primaryDBConfig);
|
||||||
|
|
||||||
|
if (secondaryDBConfig && secondaryModules) {
|
||||||
|
setupSecondaryDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = primaryDB;
|
||||||
@@ -42,10 +42,6 @@ var async = require('async'),
|
|||||||
name: 'database',
|
name: 'database',
|
||||||
description: 'Which database to use',
|
description: 'Which database to use',
|
||||||
'default': nconf.get('database') || 'redis'
|
'default': nconf.get('database') || 'redis'
|
||||||
}, {
|
|
||||||
name: 'secondary_database',
|
|
||||||
description: 'Use secondary database? (optional)',
|
|
||||||
'default': nconf.get('secondary_database') || 'none'
|
|
||||||
}],
|
}],
|
||||||
redisQuestions : [{
|
redisQuestions : [{
|
||||||
name: 'redis:host',
|
name: 'redis:host',
|
||||||
@@ -244,20 +240,18 @@ var async = require('async'),
|
|||||||
|
|
||||||
if (!install.values) {
|
if (!install.values) {
|
||||||
prompt.get(install.questions, function(err, config) {
|
prompt.get(install.questions, function(err, config) {
|
||||||
async.waterfall([
|
if (nconf.get('advanced')) {
|
||||||
function(next) {
|
prompt.get({
|
||||||
winston.info('Now configuring ' + config.database + ' database:');
|
name: 'secondary_database',
|
||||||
success(err, config, next);
|
description: 'Select secondary database',
|
||||||
},
|
'default': nconf.get('secondary_database') || 'none'
|
||||||
function(config, next) {
|
}, function(err, dbConfig) {
|
||||||
winston.info('Now configuring ' + config.secondary_database + ' database:');
|
config.secondary_database = dbConfig.secondary_database;
|
||||||
if (config.secondary_database && ALLOWED_DATABASES.indexOf(config.secondary_database) !== -1) {
|
configureDatabases(err, config);
|
||||||
getSecondaryDatabaseModules(config, next);
|
});
|
||||||
} else {
|
} else {
|
||||||
next(err, config);
|
configureDatabases(err, config);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
], completeConfigSetup);
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Use provided values, fall back to defaults
|
// Use provided values, fall back to defaults
|
||||||
@@ -282,6 +276,23 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function configureDatabases(err, config) {
|
||||||
|
async.waterfall([
|
||||||
|
function(next) {
|
||||||
|
winston.info('Now configuring ' + config.database + ' database:');
|
||||||
|
success(err, config, next);
|
||||||
|
},
|
||||||
|
function(config, next) {
|
||||||
|
winston.info('Now configuring ' + config.secondary_database + ' database:');
|
||||||
|
if (config.secondary_database && ALLOWED_DATABASES.indexOf(config.secondary_database) !== -1) {
|
||||||
|
getSecondaryDatabaseModules(config, next);
|
||||||
|
} else {
|
||||||
|
next(err, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
], completeConfigSetup);
|
||||||
|
}
|
||||||
|
|
||||||
function completeConfigSetup(err, config) {
|
function completeConfigSetup(err, config) {
|
||||||
config.bcrypt_rounds = 12;
|
config.bcrypt_rounds = 12;
|
||||||
config.upload_path = '/public/uploads';
|
config.upload_path = '/public/uploads';
|
||||||
|
|||||||
Reference in New Issue
Block a user