private starting: boolean
private startPromise?: Promise<void>
private readonly stateFilePath: string
- private stopping: boolean
private stopPromise?: Promise<void>
private storage?: Storage
private readonly templateStatistics: Map<string, TemplateStatistics>
handleUncaughtException()
this.started = false
this.starting = false
- this.stopping = false
this.shuttingDown = false
this.uiServerStarted = false
this.templateStatistics = new Map<string, TemplateStatistics>()
}
private async doStop (reason: StopReason): Promise<void> {
- this.stopping = true
- try {
- await this.uiServer.sendInternalRequest(
- this.uiServer.buildProtocolRequest(
- generateUUID(),
- ProcedureName.STOP_CHARGING_STATION,
- Constants.EMPTY_FROZEN_OBJECT
- )
+ await this.uiServer.sendInternalRequest(
+ this.uiServer.buildProtocolRequest(
+ generateUUID(),
+ ProcedureName.STOP_CHARGING_STATION,
+ Constants.EMPTY_FROZEN_OBJECT
)
- await this.waitChargingStationsStopped()
- await this.workerImplementation?.stop()
- this.removeAllListeners()
- this.uiServer.clearCaches()
- await this.storage?.close()
- delete this.storage
- this.started = false
- if (this.persistStateEnabled && reason === StopReason.user) {
- await writeStateFile(this.stateFilePath, false, this.logPrefix)
- }
- } finally {
- this.stopping = false
+ )
+ await this.waitChargingStationsStopped()
+ await this.workerImplementation?.stop()
+ this.removeAllListeners()
+ this.uiServer.clearCaches()
+ await this.storage?.close()
+ delete this.storage
+ this.started = false
+ if (this.persistStateEnabled && reason === StopReason.user) {
+ await writeStateFile(this.stateFilePath, false, this.logPrefix)
}
}
starting: boolean
startPromise?: Promise<void>
stateFilePath: string
- stopping: boolean
stopPromise?: Promise<void>
storage?: { close: () => Promise<void> }
templateStatistics: Map<string, unknown>
EventEmitter.call(instance as unknown as EventEmitter)
instance.started = false
instance.starting = false
- instance.stopping = false
instance.startPromise = undefined
instance.stopPromise = undefined
instance.shuttingDown = false
assert.ok(warnMock.mock.calls.length >= 1, 'idempotent stop guard must log at warn level')
})
- await it('Bootstrap.stop while stopping logs at debug', async () => {
+ await it('Bootstrap.stop while stop is in flight logs at debug', async () => {
const errorMock = mock.method(logger, 'error', () => undefined)
const debugMock = mock.method(logger, 'debug', () => undefined)
const bootstrap = buildLifecycleTestInstance(stateFilePath)