From dc900172f2e27b0c171f10ac31c252c7bd6bf53c Mon Sep 17 00:00:00 2001 From: Folzo Date: Sun, 2 Aug 2026 01:15:46 +0200 Subject: [PATCH] jean-router: detection PC via TCP connect au lieu de HTTP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TCP connect vers 8090 ou 11434 (pas de requete HTTP) - ConnectionRefused = PC allume (service down) - Timeout = PC eteint → WoL - Plus de spam HTTP vers un serveur bloque --- jean-router/app.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/jean-router/app.py b/jean-router/app.py index 407236e..d381bcc 100644 --- a/jean-router/app.py +++ b/jean-router/app.py @@ -133,24 +133,23 @@ def send_wol(): def jean_alive() -> bool: - """Verifie si le PC gaming est accessible (Jean ou Ollama)""" + """Verifie si le PC gaming est allume (TCP connect vers Jean ou Ollama)""" now = time.time() if now - jean_alive_cache["timestamp"] < 2: return jean_alive_cache["alive"] alive = False - try: - r = requests.get(f"http://{JEAN_WEB_HOST}:{JEAN_WEB_PORT}/api/presets", timeout=3) - alive = r.ok - except Exception: - pass - - if not alive: + for port in [JEAN_WEB_PORT, OLLAMA_DIRECT_PORT]: try: - r = requests.get(f"http://{OLLAMA_DIRECT_HOST}:{OLLAMA_DIRECT_PORT}/api/version", timeout=2) - alive = r.ok - except Exception: - pass + sock = socket.create_connection((JEAN_WEB_HOST, port), timeout=2) + sock.close() + alive = True + break + except ConnectionRefusedError: + alive = True # PC on, service down + break + except (socket.timeout, OSError): + continue # PC off ou inaccessible jean_alive_cache["alive"] = alive jean_alive_cache["timestamp"] = now