mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
fixed issue where meta was called before nconf loaded
This commit is contained in:
14
app.js
14
app.js
@@ -25,7 +25,8 @@
|
||||
|
||||
var fs = require('fs'),
|
||||
winston = require('winston'),
|
||||
pkg = require('./package.json');
|
||||
pkg = require('./package.json'),
|
||||
meta;
|
||||
|
||||
// Runtime environment
|
||||
global.env = process.env.NODE_ENV || 'production';
|
||||
@@ -51,13 +52,13 @@
|
||||
winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
|
||||
winston.info('');
|
||||
|
||||
var meta = require('./src/meta.js');
|
||||
|
||||
if (fs.existsSync(__dirname + '/config.json') && (!nconf.get('setup') && !nconf.get('upgrade'))) {
|
||||
// Load server-side config
|
||||
// Load server-side configs
|
||||
nconf.file({
|
||||
file: __dirname + '/config.json'
|
||||
});
|
||||
meta = require('./src/meta.js');
|
||||
|
||||
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path') + '/');
|
||||
nconf.set('upload_url', nconf.get('url') + 'uploads/');
|
||||
@@ -95,9 +96,7 @@
|
||||
});
|
||||
|
||||
} else if (nconf.get('upgrade')) {
|
||||
nconf.file({
|
||||
file: __dirname + '/config.json'
|
||||
});
|
||||
meta = require('./src/meta.js');
|
||||
|
||||
meta.configs.init(function () {
|
||||
require('./src/upgrade').upgrade();
|
||||
@@ -106,8 +105,7 @@
|
||||
// New install, ask setup questions
|
||||
if (nconf.get('setup')) {
|
||||
winston.info('NodeBB Setup Triggered via Command Line');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
winston.warn('Configuration not found, starting NodeBB setup');
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ var async = require('async'),
|
||||
prompt = require('prompt'),
|
||||
winston = require('winston'),
|
||||
reds = require('reds'),
|
||||
nconf = require('nconf');
|
||||
nconf = require('nconf'),
|
||||
|
||||
install = {
|
||||
questions: [{
|
||||
@@ -50,7 +50,9 @@ var async = require('async'),
|
||||
prompt.delimiter = '';
|
||||
|
||||
prompt.get(install.questions, function (err, config) {
|
||||
if (!config) return next(new Error('aborted'));
|
||||
if (!config) {
|
||||
return next(new Error('aborted'));
|
||||
}
|
||||
|
||||
// Translate redis properties into redis object
|
||||
config.redis = {
|
||||
@@ -63,9 +65,9 @@ var async = require('async'),
|
||||
delete config['redis:password'];
|
||||
|
||||
// Add hardcoded values
|
||||
config['bcrypt_rounds'] = 12,
|
||||
config['upload_path'] = '/public/uploads';
|
||||
config['use_port'] = (config['use_port'].slice(0, 1) === 'y') ? true : false;
|
||||
config.bcrypt_rounds = 12;
|
||||
config.upload_path = '/public/uploads';
|
||||
config.use_port = (config.use_port.slice(0, 1) === 'y') ? true : false;
|
||||
|
||||
var urlObject = url.parse(config.base_url),
|
||||
relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '',
|
||||
@@ -88,7 +90,7 @@ var async = require('async'),
|
||||
},
|
||||
function (next) {
|
||||
// Applying default database configs
|
||||
winston.info('Populating database with default configs, if not already set...')
|
||||
winston.info('Populating database with default configs, if not already set...');
|
||||
var meta = require('./meta'),
|
||||
defaults = [{
|
||||
field: 'postDelay',
|
||||
@@ -124,16 +126,22 @@ var async = require('async'),
|
||||
var Groups = require('./groups');
|
||||
|
||||
Groups.getGidFromName('Administrators', function (err, gid) {
|
||||
if (err) return next(err.message);
|
||||
if (err) {
|
||||
return next(err.message);
|
||||
}
|
||||
|
||||
if (gid) {
|
||||
Groups.get(gid, {}, function (err, groupObj) {
|
||||
if (groupObj.count > 0) {
|
||||
winston.info('Administrator found, skipping Admin setup');
|
||||
next();
|
||||
} else install.createAdmin(next);
|
||||
} else {
|
||||
install.createAdmin(next);
|
||||
}
|
||||
});
|
||||
} else install.createAdmin(next);
|
||||
} else {
|
||||
install.createAdmin(next);
|
||||
}
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
@@ -143,9 +151,9 @@ var async = require('async'),
|
||||
categories: require('./admin/categories')
|
||||
};
|
||||
|
||||
categories.getAllCategories(function(data) {
|
||||
Categories.getAllCategories(function (data) {
|
||||
if (data.categories.length === 0) {
|
||||
winston.warn('No categories found, populating instance with default categories')
|
||||
winston.warn('No categories found, populating instance with default categories');
|
||||
|
||||
fs.readFile(path.join(__dirname, '../', 'install/data/categories.json'), function (err, default_categories) {
|
||||
default_categories = JSON.parse(default_categories);
|
||||
@@ -153,8 +161,11 @@ var async = require('async'),
|
||||
async.eachSeries(default_categories, function (category, next) {
|
||||
admin.categories.create(category, next);
|
||||
}, function (err) {
|
||||
if (!err) next();
|
||||
else winston.error('Could not set up categories');
|
||||
if (!err) {
|
||||
next();
|
||||
} else {
|
||||
winston.error('Could not set up categories');
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
@@ -179,15 +190,19 @@ var async = require('async'),
|
||||
Plugins.toggleActive(pluginId, function () {
|
||||
next();
|
||||
});
|
||||
} else next();
|
||||
})
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
}, next);
|
||||
}
|
||||
], function (err) {
|
||||
if (err) {
|
||||
winston.warn('NodeBB Setup Aborted.');
|
||||
process.exit();
|
||||
} else callback();
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
},
|
||||
createAdmin: function (callback) {
|
||||
@@ -214,7 +229,9 @@ var async = require('async'),
|
||||
}],
|
||||
getAdminInfo = function (callback) {
|
||||
prompt.get(questions, function (err, results) {
|
||||
if (!results) return callback(new Error('aborted'));
|
||||
if (!results) {
|
||||
return callback(new Error('aborted'));
|
||||
}
|
||||
|
||||
nconf.set('bcrypt_rounds', 12);
|
||||
User.create(results.username, results.password, results.email, function (err, uid) {
|
||||
@@ -224,8 +241,9 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
Groups.getGidFromName('Administrators', function (err, gid) {
|
||||
if (gid) Groups.join(gid, uid, callback);
|
||||
else {
|
||||
if (gid) {
|
||||
Groups.join(gid, uid, callback);
|
||||
} else {
|
||||
Groups.create('Administrators', 'Forum Administrators', function (err, groupObj) {
|
||||
Groups.join(groupObj.gid, uid, callback);
|
||||
});
|
||||
@@ -260,7 +278,7 @@ var async = require('async'),
|
||||
var RDB = require('./redis');
|
||||
reds.createClient = function () {
|
||||
return reds.client || (reds.client = RDB);
|
||||
}
|
||||
};
|
||||
|
||||
callback(err);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user