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

@@ -33,7 +33,7 @@ function setupWinston() {
}
winston.configure({
level: nconf.get('log-level') || (global.env === 'production' ? 'info' : 'verbose'),
level: nconf.get('log-level') || (process.env.NODE_ENV === 'production' ? 'info' : 'verbose'),
format: winston.format.combine.apply(null, formats),
transports: [
new winston.transports.Console({
@@ -71,10 +71,6 @@ function loadConfig(configFile) {
nconf.set('upload_path', path.resolve(nconf.get('base_dir'), nconf.get('upload_path')));
nconf.set('upload_url', '/assets/uploads');
if (nconf.get('url')) {
nconf.set('url_parsed', url.parse(nconf.get('url')));
}
// Explicitly cast 'jobsDisabled' as Bool
var castAsBool = ['jobsDisabled'];
nconf.stores.env.readOnly = false;
@@ -87,6 +83,23 @@ function loadConfig(configFile) {
nconf.stores.env.readOnly = true;
nconf.set('runJobs', nconf.get('isPrimary') === 'true' && !nconf.get('jobsDisabled'));
// nconf defaults, if not set in config
if (!nconf.get('sessionKey')) {
nconf.set('sessionKey', 'express.sid');
}
if (nconf.get('url')) {
nconf.set('url_parsed', url.parse(nconf.get('url')));
// 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 versionCheck() {