Implement conditional reboot

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

View File

@ -297,6 +297,9 @@ 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":
uptime_seconds = os.popen("cat /proc/uptime | cut -d'.' -f1").read()
uptime_seconds = int(uptime_seconds)
if uptime_seconds > 60*60*1:
grist_callback({ "Health": "Rebooting" }) grist_callback({ "Health": "Rebooting" })
os.system("reboot") os.system("reboot")
except Exception as e: except Exception as e: