Fix system status update

This commit is contained in:
Christoph Hagen 2023-12-10 19:32:09 +01:00
parent 5e72137d0e
commit 1a1eeb6547
2 changed files with 8 additions and 11 deletions

View File

@ -54,13 +54,10 @@ final class DeviceManager {
self.serverStatus = serverStatus
}
func updateMetricsAfterSystemStart() async {
_ = try? await serverStatus.update(deviceIsConnected ? .nominal : .reducedFunctionality)
await updateDeviceConnectionMetric()
}
private func updateDeviceConnectionMetric() async {
_ = try? await deviceConnectedMetric.update(deviceIsConnected)
func updateDeviceConnectionMetrics() async {
let isConnected = deviceIsConnected
_ = try? await serverStatus.update(isConnected ? .nominal : .reducedFunctionality)
_ = try? await deviceConnectedMetric.update(isConnected)
}
private func updateMessageCountMetric() async {
@ -186,7 +183,7 @@ final class DeviceManager {
func removeDeviceConnection() async {
try? await connection?.close()
connection = nil
await updateDeviceConnectionMetric()
await updateDeviceConnectionMetrics()
}
func createNewDeviceConnection(socket: WebSocket, auth: String) async {
@ -231,6 +228,6 @@ final class DeviceManager {
}
}
log("[INFO] Socket connected")
await updateDeviceConnectionMetric()
await updateDeviceConnectionMetrics()
}
}

View File

@ -46,7 +46,7 @@ public func configure(_ app: Application) async throws {
monitor.saveCurrentListOfMetricsToLogFolder()
// Update the metric of the device and server status
await deviceManager.updateMetricsAfterSystemStart()
await deviceManager.updateDeviceConnectionMetrics()
log("[\(df.string(from: Date()))] Server started")
}