X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fworker%2FWorkerSet.ts;h=4a43e27b0601c44d3035c77411640cefd2fe798a;hb=86545028054a9b13982500366c51e7ea2503a4eb;hp=f10ca9c8ce0f4fbfbd58a10faf0f44ab6073b20a;hpb=4f02e9b46125abbf1decd1c9762c80d568a633f7;p=e-mobility-charging-stations-simulator.git diff --git a/src/worker/WorkerSet.ts b/src/worker/WorkerSet.ts index f10ca9c8..4a43e27b 100644 --- a/src/worker/WorkerSet.ts +++ b/src/worker/WorkerSet.ts @@ -92,13 +92,14 @@ export class WorkerSet extends WorkerAbstract { 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 { ) { 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)