await this.workerImplementation?.stop();
delete this.workerImplementation;
this.removeAllListeners();
- this.uiServer?.stop();
await this.storage?.close();
delete this.storage;
this.resetCounters();
public async restart(stopChargingStations?: boolean): Promise<void> {
await this.stop(stopChargingStations);
+ Configuration.getConfigurationSection<UIServerConfiguration>(ConfigurationSection.uiServer)
+ .enabled === false && this.uiServer?.stop();
await this.start();
}
this.stop()
.then(() => {
console.info(`${chalk.green('Graceful shutdown')}`);
+ this.uiServer?.stop();
// stop() asks for charging stations to stop by default
this.waitChargingStationsStopped()
.then(() => {
import {
buildConnectorsMap,
checkChargingStation,
+ checkConfiguration,
checkConnectorsConfiguration,
checkStationInfoConnectorStatus,
checkTemplate,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
(stationConfiguration?.connectorsStatus || stationConfiguration?.evsesStatus)
) {
+ checkConfiguration(stationConfiguration, this.logPrefix(), this.configurationFile);
this.initializeConnectorsOrEvsesFromFile(stationConfiguration);
} else {
this.initializeConnectorsOrEvsesFromTemplate(stationTemplate);
ChargingProfileKindType,
ChargingRateUnitType,
type ChargingSchedulePeriod,
+ type ChargingStationConfiguration,
type ChargingStationInfo,
type ChargingStationTemplate,
ChargingStationWorkerMessageEvents,
}
};
+export const checkConfiguration = (
+ stationConfiguration: ChargingStationConfiguration | undefined,
+ logPrefix: string,
+ configurationFile: string,
+): void => {
+ if (isNullOrUndefined(stationConfiguration)) {
+ const errorMsg = `Failed to read charging station configuration file ${configurationFile}`;
+ logger.error(`${logPrefix} ${errorMsg}`);
+ throw new BaseError(errorMsg);
+ }
+ if (isEmptyObject(stationConfiguration!)) {
+ const errorMsg = `Empty charging station configuration from file ${configurationFile}`;
+ logger.error(`${logPrefix} ${errorMsg}`);
+ throw new BaseError(errorMsg);
+ }
+};
+
export const checkConnectorsConfiguration = (
stationTemplate: ChargingStationTemplate,
logPrefix: string,