mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
merge
This commit is contained in:
10
app.js
10
app.js
@@ -25,6 +25,7 @@ nconf.argv().env();
|
||||
|
||||
var fs = require('fs'),
|
||||
os = require('os'),
|
||||
url = require('url'),
|
||||
async = require('async'),
|
||||
semver = require('semver'),
|
||||
winston = require('winston'),
|
||||
@@ -107,6 +108,15 @@ function loadConfig() {
|
||||
function start() {
|
||||
loadConfig();
|
||||
|
||||
// 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());
|
||||
winston.info('Initializing NodeBB v%s', pkg.version);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
var async = require('async'),
|
||||
fs = require('fs'),
|
||||
url = require('url'),
|
||||
path = require('path'),
|
||||
prompt = require('prompt'),
|
||||
winston = require('winston'),
|
||||
@@ -24,29 +23,20 @@ var install = {},
|
||||
|
||||
questions.main = [
|
||||
{
|
||||
name: 'base_url',
|
||||
name: 'url',
|
||||
description: 'URL used to access this NodeBB',
|
||||
'default': nconf.get('base_url') ? (nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '')) : 'http://localhost:4567',
|
||||
'default':
|
||||
nconf.get('url') ||
|
||||
(nconf.get('base_url') ? (nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '')) : null) || // backwards compatibility (remove for v0.7.0)
|
||||
'http://localhost:4567',
|
||||
pattern: /^http(?:s)?:\/\//,
|
||||
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
||||
},
|
||||
{
|
||||
name: 'port',
|
||||
description: 'Port number of your NodeBB',
|
||||
'default': nconf.get('port') || 4567,
|
||||
pattern: /[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]/,
|
||||
message: 'Please enter a value betweeen 1 and 65535'
|
||||
},
|
||||
{
|
||||
name: 'secret',
|
||||
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',
|
||||
@@ -175,6 +165,7 @@ function completeConfigSetup(err, config, next) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
// Add CI object
|
||||
if (install.ciVals) {
|
||||
config.test_database = {};
|
||||
@@ -185,22 +176,12 @@ function completeConfigSetup(err, config, next) {
|
||||
}
|
||||
}
|
||||
|
||||
config.bcrypt_rounds = 12;
|
||||
config.upload_path = '/public/uploads';
|
||||
|
||||
var urlObject = url.parse(config.base_url),
|
||||
server_conf = config;
|
||||
|
||||
server_conf.base_url = urlObject.protocol + '//' + urlObject.hostname;
|
||||
server_conf.use_port = urlObject.port !== null ? true : false;
|
||||
server_conf.relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '';
|
||||
|
||||
install.save(server_conf, function(err) {
|
||||
install.save(config, function(err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
setupDatabase(server_conf, next);
|
||||
setupDatabase(config, next);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -329,7 +310,6 @@ function createAdmin(callback) {
|
||||
return retryPassword(results);
|
||||
}
|
||||
|
||||
nconf.set('bcrypt_rounds', 12);
|
||||
User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
|
||||
if (err) {
|
||||
winston.warn(err.message + ' Please try again.');
|
||||
|
||||
@@ -746,7 +746,22 @@ var fs = require('fs'),
|
||||
};
|
||||
|
||||
Plugins.clearRequireCache = function(next) {
|
||||
async.map(Plugins.libraryPaths, fs.realpath, function(err, paths) {
|
||||
var cached = Object.keys(require.cache);
|
||||
async.waterfall([
|
||||
async.apply(async.map, Plugins.libraryPaths, fs.realpath),
|
||||
function(paths, next) {
|
||||
paths = paths.map(function(pluginLib) {
|
||||
var parent = path.dirname(pluginLib);
|
||||
return cached.filter(function(libPath) {
|
||||
return libPath.indexOf(parent) !== -1;
|
||||
});
|
||||
}).reduce(function(prev, cur) {
|
||||
return prev.concat(cur);
|
||||
});
|
||||
next(null, paths);
|
||||
}
|
||||
], function(err, paths) {
|
||||
console.log(paths);
|
||||
for (var x=0,numPaths=paths.length;x<numPaths;x++) {
|
||||
delete require.cache[paths[x]];
|
||||
}
|
||||
|
||||
@@ -54,16 +54,17 @@ var path = require('path'),
|
||||
topicUrls: function(next) {
|
||||
var topicUrls = [];
|
||||
|
||||
db.getSortedSetRevRange('topics:recent', 0, 49, function(err, tids) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
async.waterfall([
|
||||
function(tids, next) {
|
||||
db.getSortedSetRevRange('topics:recent', 0, -1, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
privileges.topics.filter('read', tids, 0, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], next);
|
||||
}
|
||||
privileges.topics.filter('read', tids, 0, function(err, tids) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], function(err, topics) {
|
||||
], function(err, topics) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -81,8 +82,6 @@ var path = require('path'),
|
||||
|
||||
next(null, topicUrls);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}, function(err, data) {
|
||||
if (!err) {
|
||||
|
||||
1131
src/upgrade.js
1131
src/upgrade.js
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ if(nconf.get('ssl')) {
|
||||
}
|
||||
|
||||
(function (app) {
|
||||
var port = nconf.get('PORT') || nconf.get('port');
|
||||
var port = nconf.get('port');
|
||||
|
||||
module.exports.init = function() {
|
||||
emailer.registerApp(app);
|
||||
|
||||
Reference in New Issue
Block a user