1 import Configuration from
'./utils/Configuration';
2 import { StationTemplateURL
} from
'./types/ConfigurationData';
3 import Utils from
'./utils/Utils';
4 import Wrk from
'./charging-station/Worker';
5 import logger from
'./utils/Logger';
10 logger
.debug('%s Configuration: %j', Utils
.logPrefix(), Configuration
.getConfig());
11 let numStationsTotal
= 0;
12 // Start each ChargingStation object in a worker thread
13 if (Configuration
.getStationTemplateURLs()) {
14 Configuration
.getStationTemplateURLs().forEach((stationURL
: StationTemplateURL
) => {
16 const nbStations
= stationURL
.numberOfStations
? stationURL
.numberOfStations
: 0;
17 numStationsTotal
+= nbStations
;
18 for (let index
= 1; index
<= nbStations
; index
++) {
19 const worker
= new Wrk('./dist/charging-station/StationWorker.js', {
21 templateFile
: stationURL
.file
,
23 worker
.start().catch(() => {});
26 // eslint-disable-next-line no-console
27 console
.log('Charging station start with template file ' + stationURL
.file
+ ' error ' + JSON
.stringify(error
, null, ' '));
31 console
.log('No stationTemplateURLs defined in configuration, exiting');
33 if (numStationsTotal
=== 0) {
34 console
.log('No charging station template enabled in configuration, exiting');
36 console
.log('Charging station simulator started with ' + numStationsTotal
.toString() + ' charging station(s)');
39 // eslint-disable-next-line no-console
40 console
.log('Bootstrap start error ' + JSON
.stringify(error
, null, ' '));