- // eslint-disable-next-line @typescript-eslint/no-misused-promises
- fs.watch(this.stationTemplateFile).on('change', async (): Promise<void> => {
- try {
- logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
- // Initialize
- this.initialize();
- // Restart the ATG
- if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
- this.automaticTransactionGeneration) {
- await this.automaticTransactionGeneration.stop();
- }
- this.startAutomaticTransactionGenerator();
- if (this.getEnableStatistics()) {
- this.performanceStatistics.restart();
- } else {
- this.performanceStatistics.stop();
+ fs.watch(this.stationTemplateFile, (event, filename): void => {
+ if (filename && event === 'change') {
+ try {
+ logger.debug(this.logPrefix() + ' Template file ' + this.stationTemplateFile + ' have changed, reload');
+ // Initialize
+ this.initialize();
+ // Restart the ATG
+ if (!this.stationInfo.AutomaticTransactionGenerator.enable &&
+ this.automaticTransactionGenerator) {
+ this.automaticTransactionGenerator.stop();
+ }
+ this.startAutomaticTransactionGenerator();
+ if (this.getEnableStatistics()) {
+ this.performanceStatistics.restart();
+ } else {
+ this.performanceStatistics.stop();
+ }
+ // FIXME?: restart heartbeat and WebSocket ping when their interval values have changed
+ } catch (error) {
+ logger.error(this.logPrefix() + ' Charging station template file monitoring error: %j', error);