feat(ui): add charging station options to add action
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerSet.ts
index f10ca9c8ce0f4fbfbd58a10faf0f44ab6073b20a..4a43e27b0601c44d3035c77411640cefd2fe798a 100644 (file)
@@ -92,13 +92,14 @@ export class WorkerSet extends WorkerAbstract<WorkerData> {
           resolve()
         })
       })
+      worker.unref()
       await worker.terminate()
       await waitWorkerExit
     }
     this.emitter?.emit(WorkerSetEvents.stopped, this.info)
+    this.started = false
     this.emitter?.emitDestroy()
     this.emitter?.removeAllListeners()
-    this.started = false
   }
 
   /** @inheritDoc */
@@ -147,6 +148,8 @@ export class WorkerSet extends WorkerAbstract<WorkerData> {
       ) {
         this.addWorkerSetElement()
       }
+      worker.unref()
+      worker.terminate().catch(error => this.emitter?.emit(WorkerSetEvents.error, error))
     })
     worker.on('online', this.workerOptions.poolOptions?.onlineHandler ?? EMPTY_FUNCTION)
     worker.on('exit', this.workerOptions.poolOptions?.exitHandler ?? EMPTY_FUNCTION)