Ensure performance statistics is started before connection to the OCPP
[e-mobility-charging-stations-simulator.git] / src / worker / WorkerDynamicPool.ts
index 9141c2f0b2f05ae3beb4c597731e4e256f326187..8ab960f365c986eec798c10e1f7e6d0cf1af8451 100644 (file)
@@ -4,6 +4,7 @@ import Utils from '../utils/Utils';
 import { Worker } from 'worker_threads';
 import WorkerAbstract from './WorkerAbstract';
 import { WorkerData } from '../types/Worker';
+import { WorkerUtils } from './WorkerUtils';
 
 export default class WorkerDynamicPool<T> extends WorkerAbstract {
   private pool: DynamicPool;
@@ -70,11 +71,7 @@ class DynamicPool extends DynamicThreadPool<WorkerData> {
 
   public static getInstance(min: number, max: number, workerScript: string, opts?: PoolOptions<Worker>): DynamicPool {
     if (!DynamicPool.instance) {
-      opts.exitHandler = opts?.exitHandler ?? ((code) => {
-        if (code !== 0) {
-          console.error(`Worker stopped with exit code ${code}`);
-        }
-      });
+      opts.exitHandler = opts?.exitHandler ?? WorkerUtils.defaultExitHandler;
       DynamicPool.instance = new DynamicPool(min, max, workerScript, opts);
     }
     return DynamicPool.instance;