mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 00:15:46 +01:00
closes #5271
This commit is contained in:
@@ -112,12 +112,10 @@
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
createSessionStore();
|
createSessionStore();
|
||||||
createIndices();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
winston.warn('You have no mongo password setup!');
|
winston.warn('You have no mongo password setup!');
|
||||||
createSessionStore();
|
createSessionStore();
|
||||||
createIndices();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSessionStore() {
|
function createSessionStore() {
|
||||||
@@ -137,9 +135,21 @@
|
|||||||
db: db
|
db: db
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.createIndices = function(callback) {
|
||||||
|
function createIndex(collection, index, options, callback) {
|
||||||
|
module.client.collection(collection).createIndex(index, options, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!module.client) {
|
||||||
|
winston.warn('[database/createIndices] database not initialized');
|
||||||
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
function createIndices() {
|
|
||||||
winston.info('[database] Checking database indices.');
|
winston.info('[database] Checking database indices.');
|
||||||
async.series([
|
async.series([
|
||||||
async.apply(createIndex, 'objects', {_key: 1, score: -1}, {background: true}),
|
async.apply(createIndex, 'objects', {_key: 1, score: -1}, {background: true}),
|
||||||
@@ -148,21 +158,16 @@
|
|||||||
], function (err) {
|
], function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error('Error creating index ' + err.message);
|
winston.error('Error creating index ' + err.message);
|
||||||
|
return callback(err);
|
||||||
}
|
}
|
||||||
winston.info('[database] Checking database indices done!');
|
winston.info('[database] Checking database indices done!');
|
||||||
callback(err);
|
callback();
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createIndex(collection, index, options, callback) {
|
|
||||||
db.collection(collection).createIndex(index, options, callback);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.checkCompatibility = function (callback) {
|
module.checkCompatibility = function (callback) {
|
||||||
var mongoPkg = require.main.require('./node_modules/mongodb/package.json'),
|
var mongoPkg = require.main.require('./node_modules/mongodb/package.json');
|
||||||
err = semver.lt(mongoPkg.version, '2.0.0') ? new Error('The `mongodb` package is out-of-date, please run `./nodebb setup` again.') : null;
|
var err = semver.lt(mongoPkg.version, '2.0.0') ? new Error('The `mongodb` package is out-of-date, please run `./nodebb setup` again.') : null;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
err.stacktrace = false;
|
err.stacktrace = false;
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
(function (module) {
|
(function (module) {
|
||||||
|
|
||||||
var winston = require('winston'),
|
var winston = require('winston');
|
||||||
nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
semver = require('semver'),
|
var semver = require('semver');
|
||||||
session = require('express-session'),
|
var session = require('express-session');
|
||||||
redis,
|
var redis;
|
||||||
connectRedis,
|
var connectRedis;
|
||||||
redisClient;
|
var redisClient;
|
||||||
|
|
||||||
module.questions = [
|
module.questions = [
|
||||||
{
|
{
|
||||||
@@ -107,6 +107,10 @@
|
|||||||
return cxn;
|
return cxn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.createIndices = function (callback) {
|
||||||
|
setImmediate(callback);
|
||||||
|
};
|
||||||
|
|
||||||
module.checkCompatibility = function (callback) {
|
module.checkCompatibility = function (callback) {
|
||||||
module.info(module.client, function (err, info) {
|
module.info(module.client, function (err, info) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
fs = require('fs'),
|
var fs = require('fs');
|
||||||
path = require('path'),
|
var path = require('path');
|
||||||
prompt = require('prompt'),
|
var prompt = require('prompt');
|
||||||
winston = require('winston'),
|
var winston = require('winston');
|
||||||
nconf = require('nconf'),
|
var nconf = require('nconf');
|
||||||
utils = require('../public/src/utils.js');
|
var utils = require('../public/src/utils.js');
|
||||||
|
|
||||||
|
var install = {};
|
||||||
var install = {},
|
var questions = {};
|
||||||
questions = {};
|
|
||||||
|
|
||||||
questions.main = [
|
questions.main = [
|
||||||
{
|
{
|
||||||
@@ -124,40 +123,33 @@ function setupConfig(next) {
|
|||||||
prompt.delimiter = '';
|
prompt.delimiter = '';
|
||||||
prompt.colors = false;
|
prompt.colors = false;
|
||||||
|
|
||||||
if (!install.values) {
|
async.waterfall([
|
||||||
prompt.get(questions.main, function (err, config) {
|
function (next) {
|
||||||
if (err) {
|
if (install.values) {
|
||||||
process.stdout.write('\n\n');
|
|
||||||
winston.warn('NodeBB setup ' + err.message);
|
|
||||||
process.exit();
|
|
||||||
}
|
|
||||||
|
|
||||||
configureDatabases(config, function (err, config) {
|
|
||||||
completeConfigSetup(err, config, next);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Use provided values, fall back to defaults
|
// Use provided values, fall back to defaults
|
||||||
var config = {},
|
var config = {};
|
||||||
redisQuestions = require('./database/redis').questions,
|
var redisQuestions = require('./database/redis').questions;
|
||||||
mongoQuestions = require('./database/mongo').questions,
|
var mongoQuestions = require('./database/mongo').questions;
|
||||||
allQuestions = questions.main.concat(questions.optional).concat(redisQuestions).concat(mongoQuestions);
|
var allQuestions = questions.main.concat(questions.optional).concat(redisQuestions).concat(mongoQuestions);
|
||||||
|
|
||||||
allQuestions.forEach(function (question) {
|
allQuestions.forEach(function (question) {
|
||||||
config[question.name] = install.values[question.name] || question['default'] || undefined;
|
config[question.name] = install.values[question.name] || question['default'] || undefined;
|
||||||
});
|
});
|
||||||
|
setImmediate(next, null, config);
|
||||||
configureDatabases(config, function (err, config) {
|
} else {
|
||||||
completeConfigSetup(err, config, next);
|
prompt.get(questions.main, next);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
function (config, next) {
|
||||||
|
configureDatabases(config, next);
|
||||||
|
},
|
||||||
|
function (config, next) {
|
||||||
|
completeConfigSetup(config, next);
|
||||||
|
}
|
||||||
|
], next);
|
||||||
}
|
}
|
||||||
|
|
||||||
function completeConfigSetup(err, config, next) {
|
function completeConfigSetup(config, next) {
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add CI object
|
// Add CI object
|
||||||
if (install.ciVals) {
|
if (install.ciVals) {
|
||||||
config.test_database = {};
|
config.test_database = {};
|
||||||
@@ -168,13 +160,17 @@ function completeConfigSetup(err, config, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
install.save(config, function (err) {
|
async.waterfall([
|
||||||
if (err) {
|
function (next) {
|
||||||
return next(err);
|
install.save(config, next);
|
||||||
}
|
},
|
||||||
|
function (next) {
|
||||||
require('./database').init(next);
|
require('./database').init(next);
|
||||||
});
|
},
|
||||||
|
function (next) {
|
||||||
|
require('./database').createIndices(next);
|
||||||
|
}
|
||||||
|
], next);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupDefaultConfigs(next) {
|
function setupDefaultConfigs(next) {
|
||||||
@@ -491,7 +487,6 @@ function setCopyrightWidget(next) {
|
|||||||
|
|
||||||
install.setup = function (callback) {
|
install.setup = function (callback) {
|
||||||
|
|
||||||
|
|
||||||
async.series([
|
async.series([
|
||||||
checkSetupFlag,
|
checkSetupFlag,
|
||||||
checkCIFlag,
|
checkCIFlag,
|
||||||
|
|||||||
Reference in New Issue
Block a user