fix: ensure charging stations are stopped if UI server is disabled at
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / AbstractUIServer.ts
index 133389d60b3cf18e01ad04922332121bbf0d37da..d27ea616bfe98591e9afbc8a3dff65c8f7a412df 100644 (file)
@@ -56,6 +56,7 @@ export abstract class AbstractUIServer {
   }
 
   public stop(): void {
+    this.stopHttpServer();
     this.chargingStations.clear();
   }
 
@@ -93,6 +94,12 @@ export abstract class AbstractUIServer {
     next();
   }
 
+  private stopHttpServer(): void {
+    if (this.httpServer.listening === true) {
+      this.httpServer.close();
+    }
+  }
+
   private isBasicAuthEnabled(): boolean {
     return (
       this.uiServerConfiguration.authentication?.enabled === true &&