fix(simulator): initialize charging station worker outside the
authorJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Feb 2023 20:04:09 +0000 (21:04 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Thu, 2 Feb 2023 20:04:09 +0000 (21:04 +0100)
constructor

Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts

index 113a9f1dae77e389a79a88b8367a5349088f8f7c..2bf7159539988aca847ea9d60539542dc65ddbab 100644 (file)
@@ -56,7 +56,7 @@ export class Bootstrap {
       'charging-station',
       `ChargingStationWorker${path.extname(fileURLToPath(import.meta.url))}`
     );
-    this.initialize();
+    this.initializeCounters();
     Configuration.getUIServer().enabled === true &&
       (this.uiServer = UIServerFactory.getUIServerImplementation(Configuration.getUIServer()));
     Configuration.getPerformanceStorage().enabled === true &&
@@ -81,7 +81,8 @@ export class Bootstrap {
         // Enable unconditionally for now
         this.logUnhandledRejection();
         this.logUncaughtException();
-        this.initialize();
+        this.initializeCounters();
+        this.initializeWorkerImplementation();
         await this.storage?.open();
         await this.workerImplementation?.start();
         this.uiServer?.start();
@@ -144,7 +145,8 @@ export class Bootstrap {
 
   public async restart(): Promise<void> {
     await this.stop();
-    this.initialize();
+    this.initializeCounters();
+    this.initializeWorkerImplementation();
     await this.start();
   }
 
@@ -238,7 +240,7 @@ export class Bootstrap {
     this.storage.storePerformanceStatistics(data) as void;
   };
 
-  private initialize() {
+  private initializeCounters() {
     this.numberOfChargingStationTemplates = 0;
     this.numberOfChargingStations = 0;
     const stationTemplateUrls = Configuration.getStationTemplateUrls();
@@ -258,7 +260,6 @@ export class Bootstrap {
       process.exit(exitCodes.noChargingStationTemplates);
     }
     this.numberOfStartedChargingStations = 0;
-    this.initializeWorkerImplementation();
   }
 
   private logUncaughtException(): void {