this.started = false
this.starting = false
this.stopping = false
+ this.initializedCounters = 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.templateStatistics = new Map<string, TemplateStatistics>()
- this.initializedCounters = false
this.initializeCounters()
Configuration.configurationChangeCallback = async () => {
if (isMainThread) {
}
)
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 workerConfiguration = Configuration.getConfigurationSection<WorkerConfiguration>(
+ ConfigurationSection.worker
+ )
console.info(
chalk.green(
`Charging stations simulator ${
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
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)