Node-Red Exec node shutdown doesn't seem to be working

Hi, I’m using a node-red flow to trigger a shutdown of my device if a button is pressed - to allow an engineer to safely shutdown and restart the devices in the field. The issue is that my Exec node does not appear to be working and I’m not getting any return in the logs to explain why. Normally, as soon as the button is clicked the device begins the shutdown process - however, when I pressed the button on my balena device it didn’t appear to do anything. The command I’m using is “sudo shutdown now”. I’m running this on a multi-container, do I need to change the command to ensure that it runs it on the hostOS rather than in my node-red container?

Thanks,
Gregor

Hello, you need to ask the supervisor to shutdown the device: https://www.balena.io/docs/reference/supervisor/supervisor-api/#post-v1shutdown

Ahh right, brilliant thanks. I’m just leaving the office now but I’ll set it up and test it on monday. Thanks for the help.

Hi, I tried putting the command $ curl -X POST --header “Content-Type:application/json”
“$BALENA_SUPERVISOR_ADDRESS/v1/shutdown?apikey=$BALENA_SUPERVISOR_API_KEY” but when I pressed the button to trigger a shutdown I got this in the logs:

/bin/sh: 1: curl: not found

Any ideas?

Hi,

curl is not installed in your container, can you please update your Dockerfile to install it before calling the command?

That was the issue, I’ve added that in and its working now. Thanks!

You’re welcome, please let us know if you need further support.