X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FBootstrap.ts;h=3312224278521fe7e98fc128b58c2ad5bc887fb6;hb=aa7d6d9568ce5ec481a0a230f4ae24c9ee9d44fa;hp=0fd80dde46bfc349ee91a9d55c3d8f168fbc19fd;hpb=51022aa0d811eec79514fbeb56cb9556e7168cd7;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 0fd80dde..33122242 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -6,7 +6,6 @@ import { type Worker, isMainThread } from 'node:worker_threads'; import chalk from 'chalk'; -import { ChargingStationUtils } from './ChargingStationUtils'; import type { AbstractUIServer } from './ui-server/AbstractUIServer'; import { UIServerFactory } from './ui-server/UIServerFactory'; import packageJson from '../../package.json' assert { type: 'json' }; @@ -21,7 +20,7 @@ import { type StationTemplateUrl, type Statistics, } from '../types'; -import { Configuration, Utils, logger } from '../utils'; +import { Configuration, ErrorUtils, Utils, logger } from '../utils'; import { type MessageHandler, type WorkerAbstract, WorkerFactory } from '../worker'; const moduleName = 'Bootstrap'; @@ -46,8 +45,8 @@ export class Bootstrap { private constructor() { // Enable unconditionally for now - this.logUnhandledRejection(); - this.logUncaughtException(); + ErrorUtils.handleUnhandledRejection(); + ErrorUtils.handleUncaughtException(); this.initializedCounters = false; this.started = false; this.initializeCounters(); @@ -102,11 +101,11 @@ export class Bootstrap { `Charging stations simulator ${ this.version } started with ${this.numberOfChargingStations.toString()} charging station(s) from ${this.numberOfChargingStationTemplates.toString()} configured charging station template(s) and ${ - ChargingStationUtils.workerDynamicPoolInUse() + Configuration.workerDynamicPoolInUse() ? `${Configuration.getWorker().poolMinSize?.toString()}/` : '' }${this.workerImplementation?.size}${ - ChargingStationUtils.workerPoolInUse() + Configuration.workerPoolInUse() ? `/${Configuration.getWorker().poolMaxSize?.toString()}` : '' } worker(s) concurrently running in '${Configuration.getWorker().processType}' mode${ @@ -257,18 +256,6 @@ export class Bootstrap { } } - private logUncaughtException(): void { - process.on('uncaughtException', (error: Error) => { - console.error(chalk.red('Uncaught exception: '), error); - }); - } - - private logUnhandledRejection(): void { - process.on('unhandledRejection', (reason: unknown) => { - console.error(chalk.red('Unhandled rejection: '), reason); - }); - } - private async startChargingStation( index: number, stationTemplateUrl: StationTemplateUrl