e841b57ec63692d173ea6f8e9d69703be546e668
1 import Configuration from
'./utils/Configuration';
2 import { StationTemplateURL
} from
'./types/ConfigurationData';
3 import Wrk from
'./charging-station/Worker';
8 let numStationsTotal
= 0;
9 let numConcurrentWorkers
= 0;
10 // Start each ChargingStation object in a worker thread
11 if (Configuration
.getStationTemplateURLs()) {
12 Configuration
.getStationTemplateURLs().forEach((stationURL
: StationTemplateURL
) => {
14 const nbStations
= stationURL
.numberOfStations
? stationURL
.numberOfStations
: 0;
15 numStationsTotal
+= nbStations
;
16 for (let index
= 1; index
<= nbStations
; index
++) {
17 const worker
= new Wrk('./dist/charging-station/StationWorker.js', {
19 templateFile
: stationURL
.file
,
21 worker
.start().catch(() => {});
22 numConcurrentWorkers
= worker
.concurrentWorkers
;
25 // eslint-disable-next-line no-console
26 console
.log('Charging station start with template file ' + stationURL
.file
+ ' error ' + JSON
.stringify(error
, null, ' '));
30 console
.log('No stationTemplateURLs defined in configuration, exiting');
32 if (numStationsTotal
=== 0) {
33 console
.log('No charging station template enabled in configuration, exiting');
35 console
.log('Charging station simulator started with ' + numStationsTotal
.toString() + ' charging station(s) of ' + numConcurrentWorkers
.toString() + ' concurrently running');
38 // eslint-disable-next-line no-console
39 console
.log('Bootstrap start error ' + JSON
.stringify(error
, null, ' '));