Update idle detection threshold to 4 hours

This commit is contained in:
vvzvlad 2025-04-12 00:11:13 +03:00
parent ed2229b139
commit 3f49993f6b

View File

@ -341,13 +341,13 @@ if __name__ == "__main__":
if result["current_status_type"] == "Idle": # Check type, not message if result["current_status_type"] == "Idle": # Check type, not message
uptime_seconds = os.popen("cat /proc/uptime | cut -d'.' -f1").read() uptime_seconds = os.popen("cat /proc/uptime | cut -d'.' -f1").read()
uptime_seconds = int(uptime_seconds) uptime_seconds = int(uptime_seconds)
if uptime_seconds > 60*60*1: if uptime_seconds > 60*60*4:
reboot_count = int(current_vm.Reboots or 0) reboot_count = int(current_vm.Reboots or 0)
reboot_count += 1 reboot_count += 1
# Include reboot count in the final Grist update before rebooting # Include reboot count in the final Grist update before rebooting
grist_updates = { "Health": "Rebooting", "Reboots": reboot_count } grist_updates = { "Health": "Rebooting", "Reboots": reboot_count }
grist_callback(grist_updates) grist_callback(grist_updates)
logger.info(f"Idle detected for >1 hour (uptime: {uptime_seconds}s). Rebooting. Reboot count: {reboot_count}") logger.info(f"Idle detected for >4 hours (uptime: {uptime_seconds}s). Rebooting. Reboot count: {reboot_count}")
os.system("reboot") os.system("reboot")
break # Exit loop on success break # Exit loop on success
except Exception as e: except Exception as e: