mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +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'),
|
||||
databaseType = nconf.get('database'),
|
||||
winston = require('winston');
|
||||
primaryDBConfig = nconf.get('database'),
|
||||
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');
|
||||
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',
|
||||
description: 'Which database to use',
|
||||
'default': nconf.get('database') || 'redis'
|
||||
}, {
|
||||
name: 'secondary_database',
|
||||
description: 'Use secondary database? (optional)',
|
||||
'default': nconf.get('secondary_database') || 'none'
|
||||
}],
|
||||
redisQuestions : [{
|
||||
name: 'redis:host',
|
||||
@@ -244,20 +240,18 @@ var async = require('async'),
|
||||
|
||||
if (!install.values) {
|
||||
prompt.get(install.questions, function(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);
|
||||
if (nconf.get('advanced')) {
|
||||
prompt.get({
|
||||
name: 'secondary_database',
|
||||
description: 'Select secondary database',
|
||||
'default': nconf.get('secondary_database') || 'none'
|
||||
}, function(err, dbConfig) {
|
||||
config.secondary_database = dbConfig.secondary_database;
|
||||
configureDatabases(err, config);
|
||||
});
|
||||
} else {
|
||||
next(err, config);
|
||||
configureDatabases(err, config);
|
||||
}
|
||||
}
|
||||
], completeConfigSetup);
|
||||
});
|
||||
} else {
|
||||
// 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) {
|
||||
config.bcrypt_rounds = 12;
|
||||
config.upload_path = '/public/uploads';
|
||||
|
||||
Reference in New Issue
Block a user