repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git]
/
src
/
charging-station
/
Bootstrap.ts
diff --git
a/src/charging-station/Bootstrap.ts
b/src/charging-station/Bootstrap.ts
index 731cc477d7a406d8165c8764ea851bc06115bafe..c0dc2b3d2ff22aaeefdc221d3ccab4dce8ebc7ac 100644
(file)
--- a/
src/charging-station/Bootstrap.ts
+++ b/
src/charging-station/Bootstrap.ts
@@
-36,7
+36,6
@@
import {
handleUncaughtException,
handleUnhandledRejection,
isNotEmptyArray,
handleUncaughtException,
handleUnhandledRejection,
isNotEmptyArray,
- isNullOrUndefined,
logPrefix,
logger
} from '../utils/index.js'
logPrefix,
logger
} from '../utils/index.js'
@@
-130,7
+129,7
@@
export class Bootstrap extends EventEmitter {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
for (const stationTemplateUrl of Configuration.getStationTemplateUrls()!) {
try {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
for (const stationTemplateUrl of Configuration.getStationTemplateUrls()!) {
try {
- const nbStations = stationTemplateUrl.numberOfStations
?? 0
+ const nbStations = stationTemplateUrl.numberOfStations
for (let index = 1; index <= nbStations; index++) {
await this.startChargingStation(index, stationTemplateUrl)
}
for (let index = 1; index <= nbStations; index++) {
await this.startChargingStation(index, stationTemplateUrl)
}
@@
-156,8
+155,8
@@
export class Bootstrap extends EventEmitter {
? `/${workerConfiguration.poolMaxSize?.toString()}`
: ''
} worker(s) concurrently running in '${workerConfiguration.processType}' mode${
? `/${workerConfiguration.poolMaxSize?.toString()}`
: ''
} worker(s) concurrently running in '${workerConfiguration.processType}' mode${
- !isNullOrUndefined(this.workerImplementation?.maxElementsPerWorker)
- ? ` (${this.workerImplementation
?
.maxElementsPerWorker} charging station(s) per worker)`
+ this.workerImplementation?.maxElementsPerWorker != null
+ ? ` (${this.workerImplementation.maxElementsPerWorker} charging station(s) per worker)`
: ''
}`
)
: ''
}`
)
@@
-224,16
+223,16
@@
export class Bootstrap extends EventEmitter {
private async waitChargingStationsStopped (): Promise<string> {
return await new Promise<string>((resolve, reject) => {
const waitTimeout = setTimeout(() => {
private async waitChargingStationsStopped (): Promise<string> {
return await new Promise<string>((resolve, reject) => {
const waitTimeout = setTimeout(() => {
- const
m
essage = `Timeout ${formatDurationMilliSeconds(
+ const
timeoutM
essage = `Timeout ${formatDurationMilliSeconds(
Constants.STOP_CHARGING_STATIONS_TIMEOUT
)} reached at stopping charging stations`
Constants.STOP_CHARGING_STATIONS_TIMEOUT
)} reached at stopping charging stations`
- console.warn(chalk.yellow(
m
essage))
- reject(new Error(
m
essage))
+ console.warn(chalk.yellow(
timeoutM
essage))
+ reject(new Error(
timeoutM
essage))
}, Constants.STOP_CHARGING_STATIONS_TIMEOUT)
waitChargingStationEvents(
this,
ChargingStationWorkerMessageEvents.stopped,
}, Constants.STOP_CHARGING_STATIONS_TIMEOUT)
waitChargingStationEvents(
this,
ChargingStationWorkerMessageEvents.stopped,
- this.numberOfChargingStations
+ this.numberOf
Started
ChargingStations
)
.then(() => {
resolve('Charging stations stopped')
)
.then(() => {
resolve('Charging stations stopped')
@@
-247,7
+246,7
@@
export class Bootstrap extends EventEmitter {
private initializeWorkerImplementation (workerConfiguration: WorkerConfiguration): void {
let elementsPerWorker: number | undefined
private initializeWorkerImplementation (workerConfiguration: WorkerConfiguration): void {
let elementsPerWorker: number | undefined
- switch (workerConfiguration
?
.elementsPerWorker) {
+ switch (workerConfiguration.elementsPerWorker) {
case 'auto':
elementsPerWorker =
this.numberOfChargingStations > availableParallelism()
case 'auto':
elementsPerWorker =
this.numberOfChargingStations > availableParallelism()
@@
-374,7
+373,7
@@
export class Bootstrap extends EventEmitter {
if (isNotEmptyArray(stationTemplateUrls)) {
this.numberOfChargingStationTemplates = stationTemplateUrls.length
for (const stationTemplateUrl of stationTemplateUrls) {
if (isNotEmptyArray(stationTemplateUrls)) {
this.numberOfChargingStationTemplates = stationTemplateUrls.length
for (const stationTemplateUrl of stationTemplateUrls) {
- this.numberOfChargingStations += stationTemplateUrl.numberOfStations
?? 0
+ this.numberOfChargingStations += stationTemplateUrl.numberOfStations
}
} else {
console.warn(
}
} else {
console.warn(
@@
-414,7
+413,7
@@
export class Bootstrap extends EventEmitter {
private gracefulShutdown (): void {
this.stop()
.then(() => {
private gracefulShutdown (): void {
this.stop()
.then(() => {
- console.info(
`${chalk.green('Graceful shutdown')}`
)
+ console.info(
chalk.green('Graceful shutdown')
)
this.uiServer?.stop()
// stop() asks for charging stations to stop by default
this.waitChargingStationsStopped()
this.uiServer?.stop()
// stop() asks for charging stations to stop by default
this.waitChargingStationsStopped()
@@
-425,7
+424,7
@@
export class Bootstrap extends EventEmitter {
exit(exitCodes.gracefulShutdownError)
})
})
exit(exitCodes.gracefulShutdownError)
})
})
- .catch(
(error)
=> {
+ .catch(
error
=> {
console.error(chalk.red('Error while shutdowning charging stations simulator: '), error)
exit(exitCodes.gracefulShutdownError)
})
console.error(chalk.red('Error while shutdowning charging stations simulator: '), error)
exit(exitCodes.gracefulShutdownError)
})