export class Configuration {
private static configurationFile = path.join(
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
+ path.dirname(fileURLToPath(import.meta.url)),
'assets',
'config.json'
);
// This is intentional
}
- static setConfigurationChangeCallback(cb: () => Promise<void>): void {
+ public static setConfigurationChangeCallback(cb: () => Promise<void>): void {
Configuration.configurationChangeCallback = cb;
}
- static getLogStatisticsInterval(): number | undefined {
+ public static getLogStatisticsInterval(): number | undefined {
Configuration.warnDeprecatedConfigurationKey(
'statisticsDisplayInterval',
undefined,
: Constants.DEFAULT_LOG_STATISTICS_INTERVAL;
}
- static getUIServer(): UIServerConfiguration {
+ public static getUIServer(): UIServerConfiguration {
if (Utils.hasOwnProp(Configuration.getConfig(), 'uiWebSocketServer')) {
console.error(
chalk`{green ${Configuration.logPrefix()}} {red Deprecated configuration section 'uiWebSocketServer' usage. Use 'uiServer' instead}`
return uiServerConfiguration;
}
- static getPerformanceStorage(): StorageConfiguration {
+ public static getPerformanceStorage(): StorageConfiguration {
Configuration.warnDeprecatedConfigurationKey('URI', 'performanceStorage', "Use 'uri' instead");
let storageConfiguration: StorageConfiguration = {
enabled: false,
return storageConfiguration;
}
- static getAutoReconnectMaxRetries(): number | undefined {
+ public static getAutoReconnectMaxRetries(): number | undefined {
Configuration.warnDeprecatedConfigurationKey(
'autoReconnectTimeout',
undefined,
}
}
- static getStationTemplateUrls(): StationTemplateUrl[] | undefined {
+ public static getStationTemplateUrls(): StationTemplateUrl[] | undefined {
Configuration.warnDeprecatedConfigurationKey(
'stationTemplateURLs',
undefined,
return Configuration.getConfig()?.stationTemplateUrls;
}
- static getWorker(): WorkerConfiguration {
+ public static getWorker(): WorkerConfiguration {
Configuration.warnDeprecatedConfigurationKey(
'useWorkerPool',
undefined,
return workerConfiguration;
}
- static getLogConsole(): boolean | undefined {
+ public static workerPoolInUse(): boolean {
+ return [WorkerProcessType.dynamicPool, WorkerProcessType.staticPool].includes(
+ Configuration.getWorker().processType
+ );
+ }
+
+ public static workerDynamicPoolInUse(): boolean {
+ return Configuration.getWorker().processType === WorkerProcessType.dynamicPool;
+ }
+
+ public static getLogConsole(): boolean | undefined {
Configuration.warnDeprecatedConfigurationKey(
'consoleLog',
undefined,
: false;
}
- static getLogFormat(): string | undefined {
+ public static getLogFormat(): string | undefined {
return Utils.hasOwnProp(Configuration.getConfig(), 'logFormat')
? Configuration.getConfig()?.logFormat
: 'simple';
}
- static getLogRotate(): boolean | undefined {
+ public static getLogRotate(): boolean | undefined {
return Utils.hasOwnProp(Configuration.getConfig(), 'logRotate')
? Configuration.getConfig()?.logRotate
: true;
}
- static getLogMaxFiles(): number | string | false | undefined {
+ public static getLogMaxFiles(): number | string | false | undefined {
return (
Utils.hasOwnProp(Configuration.getConfig(), 'logMaxFiles') &&
Configuration.getConfig()?.logMaxFiles
);
}
- static getLogMaxSize(): number | string | false | undefined {
+ public static getLogMaxSize(): number | string | false | undefined {
return (
Utils.hasOwnProp(Configuration.getConfig(), 'logMaxFiles') &&
Configuration.getConfig()?.logMaxSize
);
}
- static getLogLevel(): string | undefined {
+ public static getLogLevel(): string | undefined {
return Utils.hasOwnProp(Configuration.getConfig(), 'logLevel')
? Configuration.getConfig()?.logLevel?.toLowerCase()
: 'info';
}
- static getLogFile(): string | undefined {
+ public static getLogFile(): string | undefined {
return Utils.hasOwnProp(Configuration.getConfig(), 'logFile')
? Configuration.getConfig()?.logFile
: 'combined.log';
}
- static getLogErrorFile(): string | undefined {
+ public static getLogErrorFile(): string | undefined {
Configuration.warnDeprecatedConfigurationKey(
'errorFile',
undefined,
: 'error.log';
}
- static getSupervisionUrls(): string | string[] | undefined {
+ public static getSupervisionUrls(): string | string[] | undefined {
Configuration.warnDeprecatedConfigurationKey(
'supervisionURLs',
undefined,
return Configuration.getConfig()?.supervisionUrls;
}
- static getSupervisionUrlDistribution(): SupervisionUrlDistribution | undefined {
+ public static getSupervisionUrlDistribution(): SupervisionUrlDistribution | undefined {
Configuration.warnDeprecatedConfigurationKey(
'distributeStationToTenantEqually',
undefined,
case 'EACCES':
logMsg = `${fileType} file ${file} access denied:`;
break;
+ case 'EPERM':
+ logMsg = `${fileType} file ${file} permission denied:`;
+ break;
default:
logMsg = `${fileType} file ${file} error:`;
}
- console.warn(`${chalk.green(prefix)}${chalk.yellow(`${logMsg} `)}`, error);
+ console.error(`${chalk.green(prefix)}${chalk.red(`${logMsg} `)}`, error);
+ throw error;
}
private static getDefaultPerformanceStorageUri(storageType: StorageType) {
private static buildPerformanceUriFilePath(file: string) {
return `file://${path.join(
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../'),
+ path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../'),
file
)}`;
}