await this.storage.open()
}
}
- if (
- !this.uiServerStarted &&
- Configuration.getConfigurationSection<UIServerConfiguration>(
- ConfigurationSection.uiServer
- ).enabled === true
- ) {
- this.syncUIServerTemplates()
- this.uiServer.start()
- this.uiServerStarted = true
- }
+ this.startUIServer()
// Start ChargingStation object instance in worker thread
for (const stationTemplateUrl of Configuration.getStationTemplateUrls() ?? []) {
const nbStations = stationTemplateUrl.numberOfStations
this.stop(StopReason.shutdown)
.then(() => {
logger.info(`${this.logPrefix()} ${moduleName}.gracefulShutdown: Graceful shutdown`)
- if (this.uiServerStarted) {
- this.uiServer.stop()
- this.uiServerStarted = false
- }
+ this.stopUIServer()
return exit(exitCodes.succeeded)
})
.catch((error: unknown) => {
private async restart (): Promise<void> {
await this.stop(StopReason.reload)
if (
- this.uiServerStarted &&
Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
.enabled !== true
) {
- this.uiServer.stop()
- this.uiServerStarted = false
+ this.stopUIServer()
}
this.prepareTemplateStatistics()
- this.syncUIServerTemplates()
+ if (this.uiServerStarted) {
+ this.syncUIServerTemplates()
+ }
// TODO: compare worker configuration hash to skip unnecessary re-initialization
this.initializeWorkerImplementation(
Configuration.getConfigurationSection<WorkerConfiguration>(ConfigurationSection.worker)
await this.start()
}
+ private stopUIServer (): void {
+ if (!this.uiServerStarted) {
+ return
+ }
+ this.uiServer.stop()
+ this.uiServerStarted = false
+ }
+
private syncUIServerTemplates (): void {
this.uiServer.setChargingStationTemplates(
Configuration.getStationTemplateUrls()?.map(stationTemplateUrl =>