v1.18.x
Julian Lam 10 years ago
parent d430ef3983
commit 03b106b03a

@ -111,6 +111,11 @@ function start() {
// nconf defaults, if not set in config
if (!nconf.get('upload_path')) nconf.set('upload_path', '/public/uploads');
if (!nconf.get('bcrypt_rounds')) nconf.set('bcrypt_rounds', 12);
// Parse out the relative_url and other goodies from the configured URL
var urlObject = url.parse(nconf.get('url'));
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', urlObject.pathname !== '/' ? urlObject.pathname : '');
nconf.set('port', nconf.get('port') || nconf.get('PORT') || 4567);
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
winston.info('Time: %s', (new Date()).toString());
@ -145,12 +150,6 @@ function start() {
if (schema_ok || nconf.get('check-schema') === false) {
sockets.init(webserver.server);
// Parse out the relative_url and other goodies from the configured URL
var urlObject = url.parse(nconf.get('url'));
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', urlObject.pathname);
nconf.set('port', nconf.get('port') || nconf.get('PORT') || 4567);
async.waterfall([
async.apply(plugins.ready),
async.apply(meta.templates.compile),

@ -4,15 +4,15 @@ var pkg = require('./../../package.json'),
meta = require('./../meta'),
user = require('./../user'),
plugins = require('./../plugins'),
widgets = require('../widgets');
widgets = require('../widgets'),
nconf = require('nconf');
var apiController = {};
apiController.getConfig = function(req, res, next) {
var serverConfig = require('./../../config.json');
var config = {};
config.relative_path = serverConfig.relative_path;
config.relative_path = nconf.get('relative_path');
config.version = pkg.version;
config.siteTitle = meta.config.title || meta.config.browserTitle || 'NodeBB';
config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;

@ -37,11 +37,6 @@ questions.main = [
description: 'Please enter a NodeBB secret',
'default': nconf.get('secret') || utils.generateUUID()
},
{
name: 'bind_address',
description: 'IP or Hostname to bind to',
'default': nconf.get('bind_address') || '0.0.0.0'
},
{
name: 'database',
description: 'Which database to use',

@ -3,6 +3,8 @@
var db = require('./database'),
async = require('async'),
winston = require('winston'),
fs = require('fs'),
path = require('path'),
User = require('./user'),
Topics = require('./topics'),
@ -19,7 +21,7 @@ var db = require('./database'),
schemaDate, thisSchemaDate,
// IMPORTANT: REMEMBER TO UPDATE VALUE OF latestSchema
latestSchema = Date.UTC(2014, 10, 17, 13);
latestSchema = Date.UTC(2014, 10, 29, 22);
Upgrade.check = function(callback) {
db.get('schemaDate', function(err, value) {
@ -270,7 +272,7 @@ Upgrade.upgrade = function(callback) {
function(next) {
thisSchemaDate = Date.UTC(2014, 10, 17, 13);
if (schemaDate < thisSchemaDate) {
winston.info('[2014/11/11] Updating user email digest settings');
winston.info('[2014/11/17] Updating user email digest settings');
async.waterfall([
async.apply(db.getSortedSetRange, 'users:joindate', 0, -1),
@ -290,14 +292,52 @@ Upgrade.upgrade = function(callback) {
}
], function(err) {
if (err) {
winston.error('[2014/11/11] Error encountered while updating user email digest settings');
winston.error('[2014/11/17] Error encountered while updating user email digest settings');
return next(err);
}
winston.info('[2014/11/11] Updating user email digest settings done');
winston.info('[2014/11/17] Updating user email digest settings done');
Upgrade.update(thisSchemaDate, next);
});
} else {
winston.info('[2014/11/11] Updating user email digest settings skipped');
winston.info('[2014/11/17] Updating user email digest settings skipped');
next();
}
},
function(next) {
thisSchemaDate = Date.UTC(2014, 10, 29, 22);
if (schemaDate < thisSchemaDate) {
winston.info('[2014/11/29] Updating config.json to new format');
var configPath = path.join(__dirname, '../config.json');
async.waterfall([
async.apply(fs.readFile, configPath, { encoding: 'utf-8' }),
function(config, next) {
try {
config = JSON.parse(config);
config.url = config.base_url + (config.use_port ? ':' + config.port : '') + config.relative_path;
if (config.port == '4567') delete config.port;
if (config.bcrypt_rounds == 12) delete config.bcrypt_rounds;
if (config.upload_path === '/public/uploads') delete config.upload_path;
if (config.bind_address === '0.0.0.0') delete config.bind_address;
delete config.base_url;
delete config.use_port;
delete config.relative_path;
fs.writeFile(configPath, JSON.stringify(config, null, 4), next);
} catch (err) {
return next(err);
}
}
], function(err) {
if (err) {
winston.error('[2014/11/29] Error encountered while updating config.json to new format');
return next(err);
}
winston.info('[2014/11/29] Updating config.json to new format done');
Upgrade.update(thisSchemaDate, next);
});
} else {
winston.info('[2014/11/29] Updating config.json to new format skipped');
next();
}
}

Loading…
Cancel
Save