Files
NodeBB/app.js

83 lines
2.8 KiB
JavaScript
Raw Normal View History

2015-07-21 11:23:16 -04:00
/*
NodeBB - A better forum platform for the modern web
https://github.com/NodeBB/NodeBB/
2021-11-15 18:27:22 -05:00
Copyright (C) 2013-2021 NodeBB Inc.
2015-07-21 11:23:16 -04:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2017-02-18 01:56:23 -07:00
'use strict';
2015-07-21 11:23:16 -04:00
require('./require-main');
2017-04-12 15:22:58 -06:00
const nconf = require('nconf');
nconf.argv().env({
separator: '__',
});
2015-07-21 11:23:16 -04:00
const winston = require('winston');
const path = require('path');
const file = require('./src/file');
2015-07-21 11:23:16 -04:00
process.env.NODE_ENV = process.env.NODE_ENV || 'production';
2015-07-21 11:23:16 -04:00
global.env = process.env.NODE_ENV || 'production';
// Alternate configuration file support
const configFile = path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json');
2015-09-17 21:54:12 -04:00
const configExists = file.existsSync(configFile) || (nconf.get('url') && nconf.get('secret') && nconf.get('database'));
2015-09-17 21:54:12 -04:00
const prestart = require('./src/prestart');
prestart.loadConfig(configFile);
prestart.setupWinston();
prestart.versionCheck();
winston.verbose('* using configuration stored in: %s', configFile);
2015-07-21 11:23:16 -04:00
2015-09-24 22:32:40 -04:00
if (!process.send) {
// If run using `node app`, log GNU copyright info along with server info
2021-02-03 23:59:08 -07:00
winston.info(`NodeBB v${nconf.get('version')} Copyright (C) 2013-${(new Date()).getFullYear()} NodeBB Inc.`);
2015-09-24 22:32:40 -04:00
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('');
}
2015-09-16 19:25:05 -04:00
if (nconf.get('setup') || nconf.get('install')) {
require('./src/cli/setup').setup();
2015-07-21 11:23:16 -04:00
} else if (!configExists) {
require('./install/web').install(nconf.get('port'));
} else if (nconf.get('upgrade')) {
require('./src/cli/upgrade').upgrade(true);
2015-07-21 11:23:16 -04:00
} else if (nconf.get('reset')) {
require('./src/cli/reset').reset({
theme: nconf.get('t'),
plugin: nconf.get('p'),
widgets: nconf.get('w'),
settings: nconf.get('s'),
all: nconf.get('a'),
2016-12-05 10:23:28 -05:00
});
2015-09-16 19:25:05 -04:00
} else if (nconf.get('activate')) {
require('./src/cli/manage').activate(nconf.get('activate'));
feat: Allow defining active plugins in config (#10767) * Revert "Revert "feat: cross origin opener policy options (#10710)"" This reverts commit 46050ace1a65430fe1b567086727da22afab4f73. * Revert "Revert "chore(i18n): fallback strings for new resources: nodebb.admin-settings-advanced"" This reverts commit 9f291c07d3423a41550b38770620a998b45e5c55. * feat: closes #10719, don't trim children if category is marked section * feat: fire hook to allow plugins to filter the pids returned in a user profile /cc julianlam/nodebb-plugin-support-forum#14 * fix: use `user.hidePrivateData();` more consistently across user retrieval endpoints * feat: Allow defining active plugins in config resolves #10766 * fix: assign the db result to files properly * test: add tests with plugins in config * feat: better theme change handling * feat: add visual indication that plugins can't be activated * test: correct hooks * test: fix test definitions * test: remove instead of resetting nconf to avoid affecting other tests * test: ... I forgot how nconf worked * fix: remove negation * docs: improve wording of error message * feat: reduce code duplication * style: remove a redundant space * fix: remove unused imports * fix: use nconf instead of requiring config.json * fix: await... * fix: second missed await * fix: move back from getActiveIds to getActive * fix: use paths again? * fix: typo * fix: move require into the function * fix: forgot to change back to getActive * test: getActive returns only id * test: accedently commented out some stuff * feat: added note to top of plugins page if \!canChangeState Co-authored-by: Julian Lam <julian@nodebb.org> Co-authored-by: Barış Soner Uşaklı <barisusakli@gmail.com>
2022-07-25 20:04:55 +02:00
} else if (nconf.get('plugins') && typeof nconf.get('plugins') !== 'object') {
require('./src/cli/manage').listPlugins();
} else if (nconf.get('build')) {
2019-09-13 18:24:21 -04:00
require('./src/cli/manage').build(nconf.get('build'));
2017-06-01 16:24:40 -04:00
} else if (nconf.get('events')) {
require('./src/cli/manage').listEvents();
2015-09-16 19:25:05 -04:00
} else {
2016-12-23 14:45:37 +03:00
require('./src/start').start();
2015-07-21 11:23:16 -04:00
}