From de8757d59f61ef94de104ad9a354a8b582f7432c Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Fri, 11 Apr 2025 01:30:02 +0300 Subject: [PATCH] Implement conditional reboot --- checker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index c811857..9cad7b7 100644 --- a/checker.py +++ b/checker.py @@ -297,8 +297,11 @@ if __name__ == "__main__": grist_callback({ "Health": result["status"] }) logger.info(f"Status: {result['status']} ()") if result["status"] == "Idle": - grist_callback({ "Health": "Rebooting" }) - os.system("reboot") + 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" }) + os.system("reboot") except Exception as e: logger.error(f"Error on attempt {attempt+1}/3: {e}") if attempt == 2: