X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcharging-station%2FBootstrap.ts;h=db3c62448877e08cde03de80e7352fed279ba8e7;hb=248f70eff6b955b177f0bbd9ca84356c3b99d72e;hp=88c79f4b3ac77b994bc8094a60e35c0b7fa1eae9;hpb=a51a4ead39e6926f7f63c6eb6871c59fe9b555b7;p=e-mobility-charging-stations-simulator.git diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 88c79f4b..db3c6244 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -2,6 +2,7 @@ import { EventEmitter } from 'node:events'; import { dirname, extname, join } from 'node:path'; +import { exit } from 'node:process'; import { fileURLToPath } from 'node:url'; import { isMainThread } from 'node:worker_threads'; @@ -99,7 +100,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 { @@ -162,7 +163,7 @@ export class Bootstrap extends EventEmitter { Configuration.workerDynamicPoolInUse() && console.warn( chalk.yellow( - 'Charging stations simulator is using dynamic pool mode. This is an experimental feature with known issues.\nPlease consider using static pool or worker set mode instead', + 'Charging stations simulator is using dynamic pool mode. This is an experimental feature with known issues.\nPlease consider using fixed pool or worker set mode instead', ), ); console.info(chalk.green('Worker set/pool information:'), this.workerImplementation?.info); @@ -187,7 +188,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([ @@ -258,7 +259,7 @@ export class Bootstrap extends EventEmitter { // logger.debug( // `${this.logPrefix()} ${moduleName}.messageHandler: Worker channel message received: ${JSON.stringify( // msg, - // null, + // undefined, // 2, // )}`, // ); @@ -296,7 +297,7 @@ export class Bootstrap extends EventEmitter { throw new BaseError( `Unknown charging station worker event: '${ msg.event - }' received with data: ${JSON.stringify(msg.data, null, 2)}`, + }' received with data: ${JSON.stringify(msg.data, undefined, 2)}`, ); } } catch (error) { @@ -354,13 +355,13 @@ export class Bootstrap extends EventEmitter { console.warn( chalk.yellow("'stationTemplateUrls' not defined or empty in configuration, exiting"), ); - process.exit(exitCodes.missingChargingStationsConfiguration); + exit(exitCodes.missingChargingStationsConfiguration); } if (this.numberOfChargingStations === 0) { console.warn( chalk.yellow('No charging station template enabled in configuration, exiting'), ); - process.exit(exitCodes.noChargingStationTemplates); + exit(exitCodes.noChargingStationTemplates); } this.initializedCounters = true; } @@ -388,14 +389,14 @@ export class Bootstrap extends EventEmitter { } private gracefulShutdown = (): void => { - console.info(`${chalk.green('Graceful shutdown')}`); this.stop() .then(() => { - process.exit(exitCodes.succeeded); + console.info(`${chalk.green('Graceful shutdown')}`); + exit(exitCodes.succeeded); }) .catch((error) => { console.error(chalk.red('Error while shutdowning charging stations simulator: '), error); - process.exit(exitCodes.gracefulShutdownError); + exit(exitCodes.gracefulShutdownError); }); };