private constructor() {
this.started = false;
this.workerScript = path.join(path.resolve(__dirname, '../'), 'charging-station', 'StationWorker.js');
+ Configuration.setConfigurationChangeCallback(async () => this.restart());
}
public static getInstance(): Bootstrap {
import ConfigurationData, { StationTemplateURL } from '../types/ConfigurationData';
-import Bootstrap from '../charging-station/Bootstrap';
import { WorkerProcessType } from '../types/Worker';
import fs from 'fs';
import path from 'path';
private static configurationFilePath = path.join(path.resolve(__dirname, '../'), 'assets', 'config.json');
private static configurationFileWatcher: fs.FSWatcher;
private static configuration: ConfigurationData;
+ private static configurationChangeCallback: () => Promise<void>;
+
+ static setConfigurationChangeCallback(cb: () => Promise<void>): void {
+ Configuration.configurationChangeCallback = cb;
+ }
static getStatisticsDisplayInterval(): number {
// Read conf
return fs.watch(Configuration.configurationFilePath).on('change', async (e): Promise<void> => {
// Nullify to force configuration file reading
Configuration.configuration = null;
- await Bootstrap.getInstance().restart();
+ if (!Configuration.isUndefined(Configuration.configurationChangeCallback)) {
+ await Configuration.configurationChangeCallback();
+ }
});
}