Update system_monitor.py
This commit is contained in:
+3
-3
@@ -340,8 +340,8 @@ def on_connect(client, userdata, flags, reason_code, properties=None):
|
|||||||
logger.error(f"❌ MQTT connection error. Code: {reason_code}")
|
logger.error(f"❌ MQTT connection error. Code: {reason_code}")
|
||||||
|
|
||||||
def on_disconnect(client, userdata, disconnect_flags, reason_code, properties=None):
|
def on_disconnect(client, userdata, disconnect_flags, reason_code, properties=None):
|
||||||
logger.warning(f"⚠️ Disconnected from MQTT broker! Code: {reason_code}")
|
logger.error(f"⚠️ Disconnessione rilevata a basso livello (Codice: {reason_code}). Forzo il riavvio tramite systemd...")
|
||||||
logger.info("Waiting for network return. Paho-MQTT will attempt automatic reconnection...")
|
os._exit(1)
|
||||||
|
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
global boot_recovered, current_status, cfg
|
global boot_recovered, current_status, cfg
|
||||||
@@ -495,7 +495,7 @@ def start_service():
|
|||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
logger.info("Attempting connection to MQTT broker...")
|
logger.info("Attempting connection to MQTT broker...")
|
||||||
client.connect(cfg['mqtt']['broker'], cfg['mqtt']['port'], 60)
|
client.connect(cfg['mqtt']['broker'], cfg['mqtt']['port'], 15)
|
||||||
|
|
||||||
# 2. Start network manager in background (handles reconnections automatically!)
|
# 2. Start network manager in background (handles reconnections automatically!)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
|
|||||||
Reference in New Issue
Block a user