build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / src / charging-station / Bootstrap.ts
index 66ad42d08c271a97bae602ef4de6c9469855beb7..503dfb0b7301f3f9e553e21c2a03a3f0ed34ad73 100644 (file)
@@ -194,7 +194,7 @@ export class Bootstrap extends EventEmitter {
         }
         await this.workerImplementation?.stop();
         delete this.workerImplementation;
-        this.uiServer?.stop();
+        this.removeAllListeners();
         await this.storage?.close();
         delete this.storage;
         this.resetCounters();
@@ -211,6 +211,8 @@ export class Bootstrap extends EventEmitter {
 
   public async restart(stopChargingStations?: boolean): Promise<void> {
     await this.stop(stopChargingStations);
+    Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
+      .enabled === false && this.uiServer?.stop();
     await this.start();
   }
 
@@ -229,7 +231,6 @@ export class Bootstrap extends EventEmitter {
         this.numberOfChargingStations,
       )
         .then(() => {
-          this.removeAllListeners();
           resolve('Charging stations stopped');
         })
         .catch(reject)
@@ -248,7 +249,7 @@ export class Bootstrap extends EventEmitter {
             ? Math.round(this.numberOfChargingStations / (availableParallelism() * 1.5))
             : 1;
         break;
-      case 'single':
+      case 'all':
         elementsPerWorker = this.numberOfChargingStations;
         break;
     }
@@ -407,6 +408,7 @@ export class Bootstrap extends EventEmitter {
     this.stop()
       .then(() => {
         console.info(`${chalk.green('Graceful shutdown')}`);
+        this.uiServer?.stop();
         // stop() asks for charging stations to stop by default
         this.waitChargingStationsStopped()
           .then(() => {