jean-router: WoL ne se declenche plus si Ollama repond (PC allume)

- jean_alive verifie Jean(8090) OU Ollama(11434)
- WoL seulement si les DEUX sont inaccessibles
- Logs WoL espaces a 5s au lieu de 2s
This commit is contained in:
Folzo
2026-08-02 01:13:21 +02:00
parent bb15bd8d24
commit 697e4e36c9
+12 -5
View File
@@ -133,17 +133,24 @@ def send_wol():
def jean_alive() -> bool: def jean_alive() -> bool:
"""Verifie si Jean est accessible""" """Verifie si le PC gaming est accessible (Jean ou Ollama)"""
now = time.time() now = time.time()
if now - jean_alive_cache["timestamp"] < 2: if now - jean_alive_cache["timestamp"] < 2:
return jean_alive_cache["alive"] return jean_alive_cache["alive"]
alive = False
try: try:
url = f"http://{JEAN_WEB_HOST}:{JEAN_WEB_PORT}/api/presets" r = requests.get(f"http://{JEAN_WEB_HOST}:{JEAN_WEB_PORT}/api/presets", timeout=3)
r = requests.get(url, timeout=3)
alive = r.ok alive = r.ok
except Exception: 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["alive"] = alive
jean_alive_cache["timestamp"] = now 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") log.info(f"[WoL] Jean UP apres {int(time.time() - deadline + WAKE_TIMEOUT)}s")
return return
log.info(f"[WoL] En attente... ({remaining}s restantes)") 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") log.error(f"[WoL] Jean ne repond pas apres {WAKE_TIMEOUT}s")