|
|
|
@ -16,59 +16,68 @@
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
// Configuration setup
|
|
|
|
|
var nconf = require('nconf');
|
|
|
|
|
nconf.argv().env();
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
|
|
var fs = require('fs'),
|
|
|
|
|
async = require('async'),
|
|
|
|
|
var nconf = require('nconf');
|
|
|
|
|
nconf.argv().env();
|
|
|
|
|
|
|
|
|
|
var fs = require('fs'),
|
|
|
|
|
os = require('os'),
|
|
|
|
|
semver = require('semver'),
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
path = require('path'),
|
|
|
|
|
pkg = require('./package.json'),
|
|
|
|
|
utils = require('./public/src/utils.js'),
|
|
|
|
|
meta;
|
|
|
|
|
utils = require('./public/src/utils.js');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Runtime environment
|
|
|
|
|
global.env = process.env.NODE_ENV || 'production';
|
|
|
|
|
global.env = process.env.NODE_ENV || 'production';
|
|
|
|
|
|
|
|
|
|
winston.remove(winston.transports.Console);
|
|
|
|
|
winston.add(winston.transports.Console, {
|
|
|
|
|
winston.remove(winston.transports.Console);
|
|
|
|
|
winston.add(winston.transports.Console, {
|
|
|
|
|
colorize: true
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
winston.add(winston.transports.File, {
|
|
|
|
|
winston.add(winston.transports.File, {
|
|
|
|
|
filename: 'error.log',
|
|
|
|
|
level: 'error'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
|
|
|
|
|
winston.err = function (err) {
|
|
|
|
|
// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
|
|
|
|
|
winston.err = function (err) {
|
|
|
|
|
winston.error(err.stack);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if(os.platform() === 'linux') {
|
|
|
|
|
require('child_process').exec('/usr/bin/which convert', function(err, stdout, stderr) {
|
|
|
|
|
if(err || !stdout) {
|
|
|
|
|
winston.warn('Couldn\'t find convert. Did you install imagemagick?');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Log GNU copyright info along with server info
|
|
|
|
|
winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.');
|
|
|
|
|
winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
|
|
|
|
|
winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
|
|
|
|
|
winston.info('');
|
|
|
|
|
|
|
|
|
|
// Log GNU copyright info along with server info
|
|
|
|
|
winston.info('NodeBB v' + pkg.version + ' Copyright (C) 2013 DesignCreatePlay Inc.');
|
|
|
|
|
winston.info('This program comes with ABSOLUTELY NO WARRANTY.');
|
|
|
|
|
winston.info('This is free software, and you are welcome to redistribute it under certain conditions.');
|
|
|
|
|
winston.info('');
|
|
|
|
|
|
|
|
|
|
if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
|
|
|
|
|
start();
|
|
|
|
|
} else if (nconf.get('setup') || nconf.get('install') || !fs.existsSync(__dirname + '/config.json')) {
|
|
|
|
|
setup();
|
|
|
|
|
} else if (nconf.get('upgrade')) {
|
|
|
|
|
upgrade();
|
|
|
|
|
} else/* if (nconf.get('help') */{
|
|
|
|
|
displayHelp();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf.get('upgrade') && fs.existsSync(__dirname + '/config.json')) {
|
|
|
|
|
// Load server-side configs
|
|
|
|
|
|
|
|
|
|
function start() {
|
|
|
|
|
nconf.file({
|
|
|
|
|
file: __dirname + '/config.json'
|
|
|
|
|
});
|
|
|
|
|
meta = require('./src/meta');
|
|
|
|
|
|
|
|
|
|
nconf.set('url', nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '') + nconf.get('relative_path'));
|
|
|
|
|
nconf.set('upload_url', path.join(path.sep, nconf.get('relative_path'), 'uploads', path.sep));
|
|
|
|
@ -90,6 +99,8 @@
|
|
|
|
|
winston.error('nodebb-theme-vanilla is out of date - please run npm install.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var meta = require('./src/meta');
|
|
|
|
|
|
|
|
|
|
require('./src/database').init(function(err) {
|
|
|
|
|
meta.configs.init(function () {
|
|
|
|
|
|
|
|
|
@ -114,7 +125,6 @@
|
|
|
|
|
|
|
|
|
|
var customTemplates = meta.config['theme:templates'] ? path.join(__dirname, 'node_modules', meta.config['theme:id'], meta.config['theme:templates']) : false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
utils.walk(path.join(__dirname, 'public/templates'), function (err, tplsToLoad) {
|
|
|
|
|
templates.init(tplsToLoad, customTemplates);
|
|
|
|
|
});
|
|
|
|
@ -134,8 +144,9 @@
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else if (nconf.get('setup') || nconf.get('install') || !fs.existsSync(__dirname + '/config.json')) {
|
|
|
|
|
// New install, ask setup questions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
|
if (nconf.get('setup')) {
|
|
|
|
|
winston.info('NodeBB Setup Triggered via Command Line');
|
|
|
|
|
} else {
|
|
|
|
@ -146,8 +157,7 @@
|
|
|
|
|
file: __dirname + '/config.json'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var templates = require('./public/src/templates'),
|
|
|
|
|
install = require('./src/install');
|
|
|
|
|
var install = require('./src/install');
|
|
|
|
|
|
|
|
|
|
winston.info('Welcome to NodeBB!');
|
|
|
|
|
winston.info('This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');
|
|
|
|
@ -162,19 +172,23 @@
|
|
|
|
|
|
|
|
|
|
process.exit();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (nconf.get('upgrade')) {
|
|
|
|
|
function upgrade() {
|
|
|
|
|
nconf.file({
|
|
|
|
|
file: __dirname + '/config.json'
|
|
|
|
|
});
|
|
|
|
|
require('./src/database').init(function(err) {
|
|
|
|
|
meta = require('./src/meta.js');
|
|
|
|
|
|
|
|
|
|
var meta = require('./src/meta');
|
|
|
|
|
|
|
|
|
|
require('./src/database').init(function(err) {
|
|
|
|
|
meta.configs.init(function () {
|
|
|
|
|
require('./src/upgrade').upgrade();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else/* if (nconf.get('help') */{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function displayHelp() {
|
|
|
|
|
winston.info('Usage: node app [options] [arguments]');
|
|
|
|
|
winston.info(' [NODE_ENV=development | NODE_ENV=production] node app [--start] [arguments]');
|
|
|
|
|
winston.info('');
|
|
|
|
@ -183,5 +197,4 @@
|
|
|
|
|
winston.info(' --setup configure your environment and setup NodeBB');
|
|
|
|
|
winston.info(' --upgrade upgrade NodeBB, first read: github.com/designcreateplay/NodeBB/wiki/Upgrading-NodeBB');
|
|
|
|
|
winston.info(' --start manually start NodeBB (default when no options are given)');
|
|
|
|
|
};
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|