Amélioration modules updater
Build and Push Docker Image / build-and-push (push) Successful in 34s

This commit is contained in:
xavier committed 2026-08-29 11:55:10 +02:00
1 parent b521999162
commit 3553809df3
1 file changed
+28 -2
+28 -2
View File
@@ -6,6 +6,7 @@ import time
from modules.logger import log_event
CATALOGUE_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/catalogue_dynamique.json"
LOCK_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/updater_lock.txt"
def recuperer_modeles_hf():
"""
@@ -43,6 +44,27 @@ def recuperer_modeles_hf():
return hf_models
def _do_update():
# --- SYSTÈME ANTI-SPAM (VERROU INTER-PROCESSUS) ---
now = time.time()
try:
if os.path.exists(LOCK_FILE):
with open(LOCK_FILE, "r") as f:
last_update = float(f.read().strip())
# Si la dernière MAJ date de moins d'une heure (3600 sec), on annule l'exécution de ce thread
if now - last_update < 3600:
return
except Exception:
pass # En cas d'erreur de lecture, on force la MAJ
# On pose le verrou avec le timestamp actuel pour bloquer les autres workers
try:
os.makedirs(os.path.dirname(LOCK_FILE), exist_ok=True)
with open(LOCK_FILE, "w") as f:
f.write(str(now))
except Exception as e:
log_event("WARNING", "UPDATER", f"Impossible d'écrire le verrou : {e}")
# --- FIN DU SYSTÈME ANTI-SPAM ---
ollama_host = os.getenv("OLLAMA_HOST", "http://192.168.1.20:11434")
try:
# MAJ locale Abliterated
@@ -87,12 +109,16 @@ def _do_update():
log_event("ERROR", "UPDATER", f"Erreur lors de la MAJ auto : {e}")
def trigger_update_now():
# Force la mise à jour en supprimant le verrou au préalable
if os.path.exists(LOCK_FILE):
try: os.remove(LOCK_FILE)
except: pass
threading.Thread(target=_do_update, daemon=True).start()
def update_models_background():
_do_update()
# Boucle de fond
while True:
time.sleep(7200) # Attente 2 heures
_do_update()
time.sleep(7200) # Attente 2 heures
threading.Thread(target=update_models_background, daemon=True).start()