From 621d2af22b281b7f07299200d4244fac4087c4c0 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Fri, 10 Nov 2023 15:04:20 +0100 Subject: [PATCH] Close socket on shutdown --- Sources/App/configure.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 4278251..0f7709d 100755 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -54,12 +54,14 @@ public func configure(_ app: Application) throws { print("[\(df.string(from: Date()))] Server started") // Gracefully shut down by closing potentially open socket - DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + .seconds(5)) { - _ = app.server.onShutdown.always { _ in - print("[\(df.string(from: Date()))] Server shutdown") - //await deviceManager.removeDeviceConnection() + //DispatchQueue.global(qos: .utility).asyncAfter(deadline: .now() + .seconds(5)) { + _ = app.server.onShutdown.always { _ in + print("[\(df.string(from: Date()))] Server shutdown") + asyncScheduler.schedule { + await deviceManager.removeDeviceConnection() } } + //} } private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) {