mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	first pass, #1984
This commit is contained in:
		
							
								
								
									
										10
									
								
								app.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								app.js
									
									
									
									
									
								
							@@ -25,6 +25,7 @@ nconf.argv().env();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var fs = require('fs'),
 | 
					var fs = require('fs'),
 | 
				
			||||||
	os = require('os'),
 | 
						os = require('os'),
 | 
				
			||||||
 | 
						url = require('url'),
 | 
				
			||||||
	async = require('async'),
 | 
						async = require('async'),
 | 
				
			||||||
	semver = require('semver'),
 | 
						semver = require('semver'),
 | 
				
			||||||
	winston = require('winston'),
 | 
						winston = require('winston'),
 | 
				
			||||||
@@ -107,6 +108,10 @@ function loadConfig() {
 | 
				
			|||||||
function start() {
 | 
					function start() {
 | 
				
			||||||
	loadConfig();
 | 
						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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!cluster.isWorker || process.env.cluster_setup === 'true') {
 | 
						if (!cluster.isWorker || process.env.cluster_setup === 'true') {
 | 
				
			||||||
		winston.info('Time: %s', (new Date()).toString());
 | 
							winston.info('Time: %s', (new Date()).toString());
 | 
				
			||||||
		winston.info('Initializing NodeBB v%s', pkg.version);
 | 
							winston.info('Initializing NodeBB v%s', pkg.version);
 | 
				
			||||||
@@ -140,7 +145,10 @@ function start() {
 | 
				
			|||||||
				if (schema_ok || nconf.get('check-schema') === false) {
 | 
									if (schema_ok || nconf.get('check-schema') === false) {
 | 
				
			||||||
					sockets.init(webserver.server);
 | 
										sockets.init(webserver.server);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
 | 
										// 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);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					async.waterfall([
 | 
										async.waterfall([
 | 
				
			||||||
						async.apply(plugins.ready),
 | 
											async.apply(plugins.ready),
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var async = require('async'),
 | 
					var async = require('async'),
 | 
				
			||||||
	fs = require('fs'),
 | 
						fs = require('fs'),
 | 
				
			||||||
	url = require('url'),
 | 
					 | 
				
			||||||
	path = require('path'),
 | 
						path = require('path'),
 | 
				
			||||||
	prompt = require('prompt'),
 | 
						prompt = require('prompt'),
 | 
				
			||||||
	winston = require('winston'),
 | 
						winston = require('winston'),
 | 
				
			||||||
@@ -24,19 +23,15 @@ var install = {},
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
questions.main = [
 | 
					questions.main = [
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		name: 'base_url',
 | 
							name: 'url',
 | 
				
			||||||
		description: 'URL used to access this NodeBB',
 | 
							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)?:\/\//,
 | 
							pattern: /^http(?:s)?:\/\//,
 | 
				
			||||||
		message: 'Base URL must begin with \'http://\' or \'https://\'',
 | 
							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',
 | 
							name: 'secret',
 | 
				
			||||||
		description: 'Please enter a NodeBB secret',
 | 
							description: 'Please enter a NodeBB secret',
 | 
				
			||||||
@@ -175,6 +170,7 @@ function completeConfigSetup(err, config, next) {
 | 
				
			|||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		return next(err);
 | 
							return next(err);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Add CI object
 | 
						// Add CI object
 | 
				
			||||||
	if (install.ciVals) {
 | 
						if (install.ciVals) {
 | 
				
			||||||
		config.test_database = {};
 | 
							config.test_database = {};
 | 
				
			||||||
@@ -185,22 +181,12 @@ function completeConfigSetup(err, config, next) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	config.bcrypt_rounds = 12;
 | 
						install.save(config, function(err) {
 | 
				
			||||||
	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) {
 | 
					 | 
				
			||||||
		if (err) {
 | 
							if (err) {
 | 
				
			||||||
			return next(err);
 | 
								return next(err);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		setupDatabase(server_conf, next);
 | 
							setupDatabase(config, next);
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -329,7 +315,6 @@ function createAdmin(callback) {
 | 
				
			|||||||
				return retryPassword(results);
 | 
									return retryPassword(results);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			nconf.set('bcrypt_rounds', 12);
 | 
					 | 
				
			||||||
			User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
 | 
								User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
 | 
				
			||||||
				if (err) {
 | 
									if (err) {
 | 
				
			||||||
					winston.warn(err.message + ' Please try again.');
 | 
										winston.warn(err.message + ' Please try again.');
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,7 +34,7 @@ if(nconf.get('ssl')) {
 | 
				
			|||||||
(function (app) {
 | 
					(function (app) {
 | 
				
			||||||
	"use strict";
 | 
						"use strict";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var	port = nconf.get('PORT') || nconf.get('port');
 | 
						var	port = nconf.get('port') || nconf.get('PORT') || 4567;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	logger.init(app);
 | 
						logger.init(app);
 | 
				
			||||||
	emailer.registerApp(app);
 | 
						emailer.registerApp(app);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user