X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fcharging-station%2FBootstrap.ts;h=66b2d5f835146782bdb9a703b5002c9ab540146c;hb=6501eda9e69fff639911308b3f2de26593ae18c9;hp=7e23949ca8aca4f6dc0e93998b94bd9121634759;hpb=a60809049f58eb001d868717a1dda9ac129f8a53;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 7e23949c..66b2d5f8 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -8,9 +8,9 @@ import { isMainThread } from 'node:worker_threads'; import chalk from 'chalk'; import { availableParallelism } from 'poolifier'; +import { waitChargingStationEvents } from './Helpers'; import type { AbstractUIServer } from './ui-server/AbstractUIServer'; import { UIServerFactory } from './ui-server/UIServerFactory'; -import { waitChargingStationEvents } from './Utils'; import { version } from '../../package.json' assert { type: 'json' }; import { BaseError } from '../exception'; import { type Storage, StorageFactory } from '../performance'; @@ -45,8 +45,10 @@ import { type WorkerAbstract, WorkerFactory } from '../worker'; const moduleName = 'Bootstrap'; enum exitCodes { + succeeded = 0, missingChargingStationsConfiguration = 1, noChargingStationTemplates = 2, + gracefulShutdownError = 3, } export class Bootstrap extends EventEmitter { @@ -97,7 +99,7 @@ export class Bootstrap extends EventEmitter { performanceStorageConfiguration.uri!, this.logPrefix(), )); - Configuration.setConfigurationChangeCallback(async () => Bootstrap.getInstance().restart()); + Configuration.configurationChangeCallback = async () => Bootstrap.getInstance().restart(); } public static getInstance(): Bootstrap { @@ -185,7 +187,7 @@ export class Bootstrap extends EventEmitter { this.uiServer.buildProtocolRequest( generateUUID(), ProcedureName.STOP_CHARGING_STATION, - Constants.EMPTY_FREEZED_OBJECT, + Constants.EMPTY_FROZEN_OBJECT, ), ); await Promise.race([ @@ -389,11 +391,11 @@ export class Bootstrap extends EventEmitter { console.info(`${chalk.green('Graceful shutdown')}`); this.stop() .then(() => { - process.exit(0); + process.exit(exitCodes.succeeded); }) .catch((error) => { console.error(chalk.red('Error while shutdowning charging stations simulator: '), error); - process.exit(1); + process.exit(exitCodes.gracefulShutdownError); }); };