71edc5a97b9e004c56083f9db8ff885b67cddfa1
1 const Configuration
= require('./utils/Configuration');
2 const Utils
= require('./utils/Utils');
3 const Wrk
= require('./charging-station/Worker');
4 const fs
= require('fs');
5 const logger
= require('./utils/Logger');
10 logger
.info('%s Configuration: %j', Utils
.basicFormatLog(), Configuration
.getConfig());
11 // Start each ChargingStation object in a worker thread
12 if (Configuration
.getChargingStationTemplateURLs()) {
13 let numStationsTotal
= 0;
14 Configuration
.getChargingStationTemplateURLs().forEach((stationURL
) => {
17 const fileDescriptor
= fs
.openSync(stationURL
.file
, 'r');
18 const stationTemplate
= JSON
.parse(fs
.readFileSync(fileDescriptor
, 'utf8'));
19 fs
.closeSync(fileDescriptor
);
20 const nbStation
= (stationURL
.numberOfStation
? stationURL
.numberOfStation
: 0);
21 numStationsTotal
+= nbStation
;
22 for (let index
= 1; index
<= nbStation
; index
++) {
23 const worker
= new Wrk('./src/charging-station/StationWorker.js', {
25 template
: JSON
.parse(JSON
.stringify(stationTemplate
)),
30 // eslint-disable-next-line no-console
31 console
.log('Template file' + stationURL
.file
+ ' error' + error
);
35 const nbStation
= Configuration
.getNumberofChargingStation();
36 for (let index
= 1; index
<= nbStation
; index
++) {
37 const worker
= new Wrk('./src/charging-station/StationWorker.js', {
39 template
: JSON
.parse(JSON
.stringify(Configuration
.getChargingStationTemplate())),
45 // eslint-disable-next-line no-console
46 console
.log('Bootstrap start error ' + JSON
.stringify(error
, null, ' '));