Rework shutdown procedure
This commit is contained in:
parent
ab2a14e00b
commit
f60cb3c05a
@ -58,21 +58,15 @@ public func configure(_ app: Application) throws {
|
||||
}
|
||||
|
||||
log("[\(df.string(from: Date()))] Server started")
|
||||
|
||||
// Gracefully shut down by closing potentially open socket
|
||||
// Must be done after app is running, otherwise error is thrown
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func shutdown() {
|
||||
try? asyncScheduler.syncShutdownGracefully()
|
||||
print("[\(df.string(from: Date()))] Server shutdown")
|
||||
asyncScheduler.schedule {
|
||||
// Gracefully shut down by closing potentially open socket
|
||||
await deviceManager.removeDeviceConnection()
|
||||
try? await asyncScheduler.shutdownGracefully()
|
||||
}
|
||||
}
|
||||
|
||||
private func loadKeys(at url: URL) throws -> (deviceKey: Data, remoteKey: Data) {
|
||||
|
Loading…
Reference in New Issue
Block a user