Fix system status update
This commit is contained in:
parent
5e72137d0e
commit
1a1eeb6547
@ -53,14 +53,11 @@ final class DeviceManager {
|
|||||||
description: "The number of messages transmitted to the device")
|
description: "The number of messages transmitted to the device")
|
||||||
self.serverStatus = serverStatus
|
self.serverStatus = serverStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateMetricsAfterSystemStart() async {
|
func updateDeviceConnectionMetrics() async {
|
||||||
_ = try? await serverStatus.update(deviceIsConnected ? .nominal : .reducedFunctionality)
|
let isConnected = deviceIsConnected
|
||||||
await updateDeviceConnectionMetric()
|
_ = try? await serverStatus.update(isConnected ? .nominal : .reducedFunctionality)
|
||||||
}
|
_ = try? await deviceConnectedMetric.update(isConnected)
|
||||||
|
|
||||||
private func updateDeviceConnectionMetric() async {
|
|
||||||
_ = try? await deviceConnectedMetric.update(deviceIsConnected)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateMessageCountMetric() async {
|
private func updateMessageCountMetric() async {
|
||||||
@ -186,7 +183,7 @@ final class DeviceManager {
|
|||||||
func removeDeviceConnection() async {
|
func removeDeviceConnection() async {
|
||||||
try? await connection?.close()
|
try? await connection?.close()
|
||||||
connection = nil
|
connection = nil
|
||||||
await updateDeviceConnectionMetric()
|
await updateDeviceConnectionMetrics()
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNewDeviceConnection(socket: WebSocket, auth: String) async {
|
func createNewDeviceConnection(socket: WebSocket, auth: String) async {
|
||||||
@ -231,6 +228,6 @@ final class DeviceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
log("[INFO] Socket connected")
|
log("[INFO] Socket connected")
|
||||||
await updateDeviceConnectionMetric()
|
await updateDeviceConnectionMetrics()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public func configure(_ app: Application) async throws {
|
|||||||
monitor.saveCurrentListOfMetricsToLogFolder()
|
monitor.saveCurrentListOfMetricsToLogFolder()
|
||||||
|
|
||||||
// Update the metric of the device and server status
|
// Update the metric of the device and server status
|
||||||
await deviceManager.updateMetricsAfterSystemStart()
|
await deviceManager.updateDeviceConnectionMetrics()
|
||||||
|
|
||||||
log("[\(df.string(from: Date()))] Server started")
|
log("[\(df.string(from: Date()))] Server started")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user