Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
'basic-ftp',
'chalk',
'date-fns',
'basic-ftp',
'chalk',
'date-fns',
'http-status-codes',
'logform',
'mnemonist',
'http-status-codes',
'logform',
'mnemonist',
this.started = false
this.starting = false
this.stopping = false
this.started = false
this.starting = false
this.stopping = false
+ this.initializedCounters = false
this.uiServerStarted = false
this.uiServerStarted = false
+ this.templateStatistics = new Map<string, TemplateStatistics>()
+ this.initializeWorkerImplementation(
+ Configuration.getConfigurationSection<WorkerConfiguration>(ConfigurationSection.worker)
+ )
this.uiServer = UIServerFactory.getUIServerImplementation(
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
)
this.uiServer = UIServerFactory.getUIServerImplementation(
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
)
- this.templateStatistics = new Map<string, TemplateStatistics>()
- this.initializedCounters = false
this.initializeCounters()
Configuration.configurationChangeCallback = async () => {
if (isMainThread) {
this.initializeCounters()
Configuration.configurationChangeCallback = async () => {
if (isMainThread) {
}
)
this.initializeCounters()
}
)
this.initializeCounters()
- const workerConfiguration = Configuration.getConfigurationSection<WorkerConfiguration>(
- ConfigurationSection.worker
- )
- this.initializeWorkerImplementation(workerConfiguration)
- await this.workerImplementation?.start()
+ // eslint-disable-next-line @typescript-eslint/unbound-method
+ if (isAsyncFunction(this.workerImplementation?.start)) {
+ await this.workerImplementation.start()
+ } else {
+ (this.workerImplementation?.start as () => void)()
+ }
const performanceStorageConfiguration =
Configuration.getConfigurationSection<StorageConfiguration>(
ConfigurationSection.performanceStorage
const performanceStorageConfiguration =
Configuration.getConfigurationSection<StorageConfiguration>(
ConfigurationSection.performanceStorage
+ const workerConfiguration = Configuration.getConfigurationSection<WorkerConfiguration>(
+ ConfigurationSection.worker
+ )
console.info(
chalk.green(
`Charging stations simulator ${
console.info(
chalk.green(
`Charging stations simulator ${
console.error(chalk.red('Error while waiting for charging stations to stop: '), error)
}
await this.workerImplementation?.stop()
console.error(chalk.red('Error while waiting for charging stations to stop: '), error)
}
await this.workerImplementation?.stop()
- delete this.workerImplementation
this.removeAllListeners()
this.uiServer.clearCaches()
this.initializedCounters = false
this.removeAllListeners()
this.uiServer.clearCaches()
this.initializedCounters = false
private async restart (): Promise<void> {
await this.stop()
private async restart (): Promise<void> {
await this.stop()
+ // FIXME: initialize worker implementation only if the worker section has changed
+ this.initializeWorkerImplementation(
+ Configuration.getConfigurationSection<WorkerConfiguration>(ConfigurationSection.worker)
+ )
if (
this.uiServerStarted &&
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
if (
this.uiServerStarted &&
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
if (connectorStatus?.transactionStarted === true) {
chargingProfile.chargingSchedule.startSchedule = connectorStatus.transactionStart
}
if (connectorStatus?.transactionStarted === true) {
chargingProfile.chargingSchedule.startSchedule = connectorStatus.transactionStart
}
- // FIXME: Handle relative charging profile duration
+ // FIXME: handle relative charging profile duration
/**
* Starts the worker pool/set.
*/
/**
* Starts the worker pool/set.
*/
- public abstract start (): Promise<void>
+ public abstract start (): void | Promise<void>
/**
* Stops the worker pool/set.
*/
/**
* Stops the worker pool/set.
*/
poolMaxSize: DEFAULT_POOL_MAX_SIZE,
elementsPerWorker: DEFAULT_ELEMENTS_PER_WORKER,
poolOptions: {
poolMaxSize: DEFAULT_POOL_MAX_SIZE,
elementsPerWorker: DEFAULT_ELEMENTS_PER_WORKER,
poolOptions: {
enableEvents: true,
restartWorkerOnError: true,
errorHandler: defaultErrorHandler,
enableEvents: true,
restartWorkerOnError: true,
errorHandler: defaultErrorHandler,
- public async start (): Promise<void> {
- // This is intentional
+ public start (): void {
+ this.pool.start()
- public async start (): Promise<void> {
- // This is intentional
+ public start (): void {
+ this.pool.start()
this.emitter?.emit(WorkerSetEvents.stopped, this.info)
this.started = false
this.emitter?.emitDestroy()
this.emitter?.emit(WorkerSetEvents.stopped, this.info)
this.started = false
this.emitter?.emitDestroy()
- this.emitter?.removeAllListeners()