Best practice Balena shutdown/reboot RPI4 via Python

Hello,
what is the best practice to shutdown or reboot the Pi4 Balena via Python?

I tried
via subprocess or systemctl (not found)

os.system("sudo shutdown -r now")
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Failed to talk to init daemon.

How should one shutdown the system or reboot it? Thanks

Hi. You can call the supervisor using the HTTP API: https://www.balena.io/docs/reference/supervisor/supervisor-api/. Specifically:

2 Likes

Thanks it worked!