diff --git a/jean-router/app.py b/jean-router/app.py index c0fd706..407236e 100644 --- a/jean-router/app.py +++ b/jean-router/app.py @@ -133,17 +133,24 @@ def send_wol(): def jean_alive() -> bool: - """Verifie si Jean est accessible""" + """Verifie si le PC gaming est accessible (Jean ou Ollama)""" now = time.time() if now - jean_alive_cache["timestamp"] < 2: return jean_alive_cache["alive"] + alive = False try: - url = f"http://{JEAN_WEB_HOST}:{JEAN_WEB_PORT}/api/presets" - r = requests.get(url, timeout=3) + r = requests.get(f"http://{JEAN_WEB_HOST}:{JEAN_WEB_PORT}/api/presets", timeout=3) alive = r.ok except Exception: - alive = False + pass + + if not alive: + try: + r = requests.get(f"http://{OLLAMA_DIRECT_HOST}:{OLLAMA_DIRECT_PORT}/api/version", timeout=2) + alive = r.ok + except Exception: + pass jean_alive_cache["alive"] = alive jean_alive_cache["timestamp"] = now @@ -174,7 +181,7 @@ def wait_for_jean(trigger_wol=True): log.info(f"[WoL] Jean UP apres {int(time.time() - deadline + WAKE_TIMEOUT)}s") return log.info(f"[WoL] En attente... ({remaining}s restantes)") - time.sleep(CHECK_INTERVAL) + time.sleep(max(CHECK_INTERVAL, 5)) log.error(f"[WoL] Jean ne repond pas apres {WAKE_TIMEOUT}s")