mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-07-16 12:40:18 +00:00
fix: make gateway watcher startup non-blocking with timeout (#4297)
start_watcher() ran synchronously in main() at boot; if _resolve_watcher_target() blocked (locked state.db, slow profile resolution, I/O stall) the server never bound its port — a startup brick. Run it on a daemon thread with a 5s join so boot proceeds even if watcher init stalls; the poll loop already runs on its own daemon thread so liveness is unchanged. Co-authored-by: minidarkmimi <minidarkmimi@users.noreply.github.com>
This commit is contained in:
@@ -593,7 +593,18 @@ def main() -> None:
|
||||
# Start the gateway session watcher for real-time SSE updates
|
||||
try:
|
||||
from api.gateway_watcher import start_watcher
|
||||
start_watcher()
|
||||
|
||||
def _start_watcher_safe():
|
||||
try:
|
||||
start_watcher()
|
||||
except Exception as e:
|
||||
print(f'[!!] WARNING: Gateway watcher failed to start: {e}', flush=True)
|
||||
|
||||
t = threading.Thread(target=_start_watcher_safe, daemon=True)
|
||||
t.start()
|
||||
t.join(timeout=5)
|
||||
if t.is_alive():
|
||||
print('[tip] Gateway watcher still initializing (non-blocking)', flush=True)
|
||||
except Exception as e:
|
||||
print(f'[!!] WARNING: Gateway watcher failed to start: {e}', flush=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user