Enanced auto-healing
This commit is contained in:
@@ -182,6 +182,27 @@ def check_auto_healing(client, status):
|
|||||||
msg = f"🛠 Auto-healing: {proc_name} offline. Riavvio {attempts+1}/3..."
|
msg = f"🛠 Auto-healing: {proc_name} offline. Riavvio {attempts+1}/3..."
|
||||||
client.publish(f"devices/{CLIENT_ID}/logs", msg)
|
client.publish(f"devices/{CLIENT_ID}/logs", msg)
|
||||||
send_telegram_message(msg)
|
send_telegram_message(msg)
|
||||||
|
|
||||||
|
# --- INIZIO MODIFICA: RESET HARDWARE SPECIFICO PER MMDVMHOST ---
|
||||||
|
if proc_name.lower() == "mmdvmhost" and GPIO_AVAILABLE:
|
||||||
|
logger.info("Esecuzione RESET HAT automatico pre-riavvio MMDVMHost...")
|
||||||
|
try:
|
||||||
|
RESET_PIN = 21 # Assicurati che il PIN sia quello corretto per i tuoi nodi
|
||||||
|
GPIO.setwarnings(False)
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setup(RESET_PIN, GPIO.OUT)
|
||||||
|
# Impulso LOW per resettare
|
||||||
|
GPIO.output(RESET_PIN, GPIO.LOW)
|
||||||
|
time.sleep(0.5)
|
||||||
|
GPIO.output(RESET_PIN, GPIO.HIGH)
|
||||||
|
GPIO.cleanup(RESET_PIN)
|
||||||
|
# Diamo tempo al microcontrollore di riavviarsi
|
||||||
|
time.sleep(1.5)
|
||||||
|
client.publish(f"devices/{CLIENT_ID}/logs", "🔌 Impulso GPIO (Reset MMDVM) inviato!")
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Errore GPIO in auto-healing: {e}")
|
||||||
|
# --- FINE MODIFICA ---
|
||||||
|
|
||||||
subprocess.run(["sudo", "systemctl", "restart", proc_name])
|
subprocess.run(["sudo", "systemctl", "restart", proc_name])
|
||||||
elif attempts == 3:
|
elif attempts == 3:
|
||||||
msg = f"🚨 CRITICO: {proc_name} fallito!"
|
msg = f"🚨 CRITICO: {proc_name} fallito!"
|
||||||
|
|||||||
Reference in New Issue
Block a user