feat: move export functions into child processes

This commit is contained in:
Barış Soner Uşaklı
2020-06-23 00:23:46 -04:00
parent 54310d69e4
commit 8383992dcc
12 changed files with 360 additions and 193 deletions

View File

@@ -1,7 +1,6 @@
'use strict';
const nconf = require('nconf');
const url = require('url');
const winston = require('winston');
const start = module.exports;
@@ -9,8 +8,6 @@ const start = module.exports;
start.start = async function () {
const db = require('./database');
setupConfigs();
printStartupInfo();
addProcessHandlers();
@@ -81,21 +78,6 @@ async function runUpgrades() {
}
}
function setupConfigs() {
// nconf defaults, if not set in config
if (!nconf.get('sessionKey')) {
nconf.set('sessionKey', 'express.sid');
}
// Parse out the relative_url and other goodies from the configured URL
const urlObject = url.parse(nconf.get('url'));
const relativePath = urlObject.pathname !== '/' ? urlObject.pathname.replace(/\/+$/, '') : '';
nconf.set('base_url', urlObject.protocol + '//' + urlObject.host);
nconf.set('secure', urlObject.protocol === 'https:');
nconf.set('use_port', !!urlObject.port);
nconf.set('relative_path', relativePath);
nconf.set('port', nconf.get('PORT') || nconf.get('port') || urlObject.port || (nconf.get('PORT_ENV_VAR') ? nconf.get(nconf.get('PORT_ENV_VAR')) : false) || 4567);
}
function printStartupInfo() {
if (nconf.get('isPrimary') === 'true') {
winston.info('Initializing NodeBB v%s %s', nconf.get('version'), nconf.get('url'));