X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FBootstrap.ts;h=d1e2efd363f3066cea99c1b6558bf23823052caa;hb=f0227f390d3f6e303bc54a96c16c075e9de46ad6;hp=516730b9ec87da6d25e0561cd39bbb7b2c763832;hpb=89b7a234c161f2c68b6a9499ff698488e1a35c6b;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 516730b9..d1e2efd3 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -14,6 +14,7 @@ import { ChargingStationData, ChargingStationWorkerData, ChargingStationWorkerMessage, + ChargingStationWorkerMessageData, ChargingStationWorkerMessageEvents, } from '../types/ChargingStationWorker'; import { StationTemplateUrl } from '../types/ConfigurationData'; @@ -31,7 +32,10 @@ import UIServerFactory from './ui-server/UIServerFactory'; const moduleName = 'Bootstrap'; -export default class Bootstrap { +const missingChargingStationsConfigurationExitCode = 1; +const noChargingStationTemplatesExitCode = 2; + +export class Bootstrap { private static instance: Bootstrap | null = null; private workerImplementation: WorkerAbstract | null = null; private readonly uiServer!: AbstractUIServer; @@ -104,12 +108,13 @@ export default class Bootstrap { console.warn( chalk.yellow("'stationTemplateUrls' not defined or empty in configuration, exiting") ); + process.exit(missingChargingStationsConfigurationExitCode); } if (this.numberOfChargingStations === 0) { console.warn( chalk.yellow('No charging station template enabled in configuration, exiting') ); - process.exit(); + process.exit(noChargingStationTemplatesExitCode); } else { console.info( chalk.green( @@ -173,14 +178,14 @@ export default class Bootstrap { workerChoiceStrategy: Configuration.getWorker().poolStrategy, }, messageHandler: this.messageHandler.bind(this) as ( - msg: ChargingStationWorkerMessage + msg: ChargingStationWorkerMessage ) => void, } )); } private messageHandler( - msg: ChargingStationWorkerMessage + msg: ChargingStationWorkerMessage ): void { // logger.debug( // `${this.logPrefix()} ${moduleName}.messageHandler: Worker channel message received: ${JSON.stringify(