Best practice Balena shutdown/reboot RPI4 via Python

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: Specifically:


Thanks it worked!