v1.18.x
Barış Soner Uşaklı 7 years ago
parent 13850e3586
commit e092778ba6

@ -10,6 +10,7 @@ var less = require('less');
var async = require('async');
var uglify = require('uglify-js');
var nconf = require('nconf');
var _ = require('lodash');
var Benchpress = require('benchpressjs');
var app = express();
@ -103,14 +104,15 @@ function welcome(req, res) {
}
function install(req, res) {
var setupEnvVars = _.assign({}, process.env);
for (var i in req.body) {
if (req.body.hasOwnProperty(i) && !process.env.hasOwnProperty(i)) {
process.env[i.replace(':', '__')] = req.body[i];
setupEnvVars[i.replace(':', '__')] = req.body[i];
}
}
var child = require('child_process').fork('app', ['--setup'], {
env: process.env,
env: setupEnvVars,
});
child.on('close', function (data) {

@ -37,19 +37,22 @@ redisModule.questions = [
];
redisModule.init = function (callback) {
redisClient = redisModule.connect();
callback = callback || function () { };
redisClient = redisModule.connect({}, function (err) {
if (err) {
winston.error('NodeBB could not connect to your Redis database. Redis returned the following error', err);
return callback(err);
}
redisModule.client = redisClient;
require('./redis/main')(redisClient, redisModule);
require('./redis/hash')(redisClient, redisModule);
require('./redis/sets')(redisClient, redisModule);
require('./redis/sorted')(redisClient, redisModule);
require('./redis/list')(redisClient, redisModule);
redisModule.client = redisClient;
require('./redis/main')(redisClient, redisModule);
require('./redis/hash')(redisClient, redisModule);
require('./redis/sets')(redisClient, redisModule);
require('./redis/sorted')(redisClient, redisModule);
require('./redis/list')(redisClient, redisModule);
if (typeof callback === 'function') {
callback();
}
});
};
redisModule.initSessionStore = function (callback) {
@ -66,7 +69,8 @@ redisModule.initSessionStore = function (callback) {
}
};
redisModule.connect = function (options) {
redisModule.connect = function (options, callback) {
callback = callback || function () {};
var redis_socket_or_host = nconf.get('redis:host');
var cxn;
@ -88,7 +92,11 @@ redisModule.connect = function (options) {
cxn.on('error', function (err) {
winston.error(err.stack);
process.exit(1);
callback(err);
});
cxn.on('ready', function () {
callback();
});
if (nconf.get('redis:password')) {
@ -99,7 +107,7 @@ redisModule.connect = function (options) {
if (dbIdx >= 0) {
cxn.select(dbIdx, function (err) {
if (err) {
winston.error('NodeBB could not connect to your Redis database. Redis returned the following error', err);
winston.error('NodeBB could not select Redis database. Redis returned the following error', err);
throw err;
}
});

@ -157,16 +157,17 @@ function completeConfigSetup(config, next) {
}
}
nconf.overrides(config);
async.waterfall([
function (next) {
install.save(config, next);
},
function (next) {
require('./database').init(next);
},
function (next) {
require('./database').createIndices(next);
},
function (next) {
install.save(config, next);
},
], next);
}
@ -523,7 +524,7 @@ install.setup = function (callback) {
], function (err, results) {
if (err) {
winston.warn('NodeBB Setup Aborted.\n ' + err.stack);
process.exit();
process.exit(1);
} else {
var data = {};
if (results[6]) {

Loading…
Cancel
Save