Public Access
This commit is contained in:
1 parent
b521999162
commit
3553809df3
1 file changed
+28
-2
@@ -6,6 +6,7 @@ import time
|
|||||||
from modules.logger import log_event
|
from modules.logger import log_event
|
||||||
|
|
||||||
CATALOGUE_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/catalogue_dynamique.json"
|
CATALOGUE_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/catalogue_dynamique.json"
|
||||||
|
LOCK_FILE = "/DATA/AppData/MULTI-IA-AETHAS38/updater_lock.txt"
|
||||||
|
|
||||||
def recuperer_modeles_hf():
|
def recuperer_modeles_hf():
|
||||||
"""
|
"""
|
||||||
@@ -43,6 +44,27 @@ def recuperer_modeles_hf():
|
|||||||
return hf_models
|
return hf_models
|
||||||
|
|
||||||
def _do_update():
|
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")
|
ollama_host = os.getenv("OLLAMA_HOST", "http://192.168.1.20:11434")
|
||||||
try:
|
try:
|
||||||
# MAJ locale Abliterated
|
# MAJ locale Abliterated
|
||||||
@@ -87,12 +109,16 @@ def _do_update():
|
|||||||
log_event("ERROR", "UPDATER", f"Erreur lors de la MAJ auto : {e}")
|
log_event("ERROR", "UPDATER", f"Erreur lors de la MAJ auto : {e}")
|
||||||
|
|
||||||
def trigger_update_now():
|
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()
|
threading.Thread(target=_do_update, daemon=True).start()
|
||||||
|
|
||||||
def update_models_background():
|
def update_models_background():
|
||||||
_do_update()
|
# Boucle de fond
|
||||||
while True:
|
while True:
|
||||||
time.sleep(7200) # Attente 2 heures
|
|
||||||
_do_update()
|
_do_update()
|
||||||
|
time.sleep(7200) # Attente 2 heures
|
||||||
|
|
||||||
threading.Thread(target=update_models_background, daemon=True).start()
|
threading.Thread(target=update_models_background, daemon=True).start()
|
||||||
Reference in new issue
Block a user