Implement conditional reboot

This commit is contained in:
vvzvlad 2025-04-11 01:30:02 +03:00
parent 4e1804bb06
commit de8757d59f

View File

@ -297,8 +297,11 @@ if __name__ == "__main__":
grist_callback({ "Health": result["status"] }) grist_callback({ "Health": result["status"] })
logger.info(f"Status: {result['status']} ()") logger.info(f"Status: {result['status']} ()")
if result["status"] == "Idle": if result["status"] == "Idle":
grist_callback({ "Health": "Rebooting" }) uptime_seconds = os.popen("cat /proc/uptime | cut -d'.' -f1").read()
os.system("reboot") uptime_seconds = int(uptime_seconds)
if uptime_seconds > 60*60*1:
grist_callback({ "Health": "Rebooting" })
os.system("reboot")
except Exception as e: except Exception as e:
logger.error(f"Error on attempt {attempt+1}/3: {e}") logger.error(f"Error on attempt {attempt+1}/3: {e}")
if attempt == 2: if attempt == 2: