X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Findex.js;h=71edc5a97b9e004c56083f9db8ff885b67cddfa1;hb=fa098a85e622e86cf403edc783616ec990eaeb91;hp=a1a5c61bf1327a749661dff327ae04a2e6181bb7;hpb=f7869514b1450a852ff707ba1a3beaecccea9ba7;p=e-mobility-charging-stations-simulator.git diff --git a/src/index.js b/src/index.js index a1a5c61b..71edc5a9 100644 --- a/src/index.js +++ b/src/index.js @@ -10,6 +10,7 @@ class Bootstrap { logger.info('%s Configuration: %j', Utils.basicFormatLog(), Configuration.getConfig()); // Start each ChargingStation object in a worker thread if (Configuration.getChargingStationTemplateURLs()) { + let numStationsTotal = 0; Configuration.getChargingStationTemplateURLs().forEach((stationURL) => { try { // load file @@ -17,11 +18,12 @@ class Bootstrap { const stationTemplate = JSON.parse(fs.readFileSync(fileDescriptor, 'utf8')); fs.closeSync(fileDescriptor); const nbStation = (stationURL.numberOfStation ? stationURL.numberOfStation : 0); + numStationsTotal += nbStation; for (let index = 1; index <= nbStation; index++) { const worker = new Wrk('./src/charging-station/StationWorker.js', { index, template: JSON.parse(JSON.stringify(stationTemplate)), - }); + }, numStationsTotal); worker.start(); } } catch (error) { @@ -35,7 +37,7 @@ class Bootstrap { const worker = new Wrk('./src/charging-station/StationWorker.js', { index, template: JSON.parse(JSON.stringify(Configuration.getChargingStationTemplate())), - }); + }, nbStation); worker.start(); } }