Close socket on shutdown

This commit is contained in:
Christoph Hagen 2023-11-10 15:04:20 +01:00
parent 1369a621ad
commit 621d2af22b

View File

@ -54,12 +54,14 @@ public func configure(_ app: Application) throws {
print("[\(df.string(from: Date()))] Server started") print("[\(df.string(from: Date()))] Server started")
// Gracefully shut down by closing potentially open socket // Gracefully shut down by closing potentially open socket
DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + .seconds(5)) { //DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + .seconds(5)) {
_ = app.server.onShutdown.always { _ in _ = app.server.onShutdown.always { _ in
print("[\(df.string(from: Date()))] Server shutdown") print("[\(df.string(from: Date()))] Server shutdown")
//await deviceManager.removeDeviceConnection() asyncScheduler.schedule {
await deviceManager.removeDeviceConnection()
} }
} }
//}
} }
private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) { private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) {