I have a raspberrypi running balenaOS. I would like to restart the device from the container itself using Python in some cases. Should I call the restart function using Python SDK for this? Or is there a better alternative?
Thanks.
I have a raspberrypi running balenaOS. I would like to restart the device from the container itself using Python in some cases. Should I call the restart function using Python SDK for this? Or is there a better alternative?
Thanks.
Hi @Mc1,
The supervisor has a reboot endpoint on it’s API. Maybe you can try invoking that from the container. Interacting with the balena Supervisor - Balena Documentation
Cheers,
Erik
You can also use dbus
DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
--system \
--print-reply \
--dest=org.freedesktop.systemd1 \
/org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager.Reboot
That’s the shell version, there’s also a Python lib for interacting with dbus. Make sure to enable it in the container
io.balena.features.dbus: '1'