- private startAuthorizationFileMonitoring(): void {
- const authorizationFile = this.getAuthorizationFile();
- if (authorizationFile) {
- try {
- fs.watch(authorizationFile, (event, filename) => {
- if (filename && event === 'change') {
- try {
- logger.debug(this.logPrefix() + ' Authorization file ' + authorizationFile + ' have changed, reload');
- // Initialize authorizedTags
- this.authorizedTags = this.getAuthorizedTags();
- } catch (error) {
- logger.error(this.logPrefix() + ' Authorization file monitoring error: %j', error);
- }
- }
- });
- } catch (error) {
- FileUtils.handleFileException(this.logPrefix(), 'Authorization', authorizationFile, error);
- }
- } else {
- logger.info(this.logPrefix() + ' No authorization file given in template file ' + this.stationTemplateFile + '. Not monitoring changes');
- }
- }
-
- private startStationTemplateFileMonitoring(): void {
- try {
- 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);
- }
- }
- });
- } catch (error) {
- FileUtils.handleFileException(this.logPrefix(), 'Template', this.stationTemplateFile, error);
- }
- }
-