fix: start gateway before control channel

This commit is contained in:
Peter Steinberger
2025-12-28 09:24:43 +00:00
parent 91c9859000
commit 8dfc031c4d
3 changed files with 24 additions and 7 deletions

View File

@@ -320,6 +320,21 @@ final class GatewayProcessManager {
Task { await ControlChannel.shared.configure() }
}
func waitForGatewayReady(timeout: TimeInterval = 6) async -> Bool {
let deadline = Date().addingTimeInterval(timeout)
while Date() < deadline {
if !self.desiredActive { return false }
do {
_ = try await GatewayConnection.shared.requestRaw(method: .health, timeoutMs: 1500)
return true
} catch {
try? await Task.sleep(nanoseconds: 300_000_000)
}
}
self.appendLog("[gateway] readiness wait timed out\n")
return false
}
func clearLog() {
self.log = ""
try? FileManager.default.removeItem(atPath: LogLocator.launchdGatewayLogPath)