reboot_RPi¶
Raspberry Pi reboot manager with cooldown protection.
Provides a small helper class, RebootManager, that performs a
controlled reboot of the host Raspberry Pi while enforcing a configurable
cooldown window (4 hours by default) to prevent runaway reboot loops.
Every reboot event is persisted to reboot_log.txt so the cooldown
state survives process restarts and power cycles.
The actual reboot is triggered via the Linux Magic SysRq interface
(/proc/sysrq-trigger), which causes an immediate hardware reboot
without the orderly shutdown of services or filesystem unmount. This
is intentionally used only as a last-resort recovery mechanism when
the device enters an unrecoverable error state.
Example
Reboot in response to a watchdog event:
from utils.reboot_RPi import RebootManager
manager = RebootManager()
manager.reboot_raspberry_pi({
"type": "events",
"t": 1700000000000,
"msg": {"type": "watchdog", "value": "sensor_timeout"},
})
Note
The SysRq reboot is immediate and ungraceful; filesystem corruption is possible if writes are in progress. A 5-second delay before triggering allows pending I/O to flush, but durability is not guaranteed.
Attributes¶
Classes¶
Coordinates Raspberry Pi reboots with cooldown protection. |
Module Contents¶
- reboot_RPi.basic_logger¶
- reboot_RPi.context_logger¶
- reboot_RPi.manager¶