I’m assuming when I call this fin block sleep API, I can give it a time to pause before powering down the pi, so that means I’m meant to shut down the pi nicely? But the normal linux shutdown command isn’t available in my container (with or without sudo). And couldn’t find anything on the internet about shutting down the linux system on a Fin.
So the questions:
Do I actually need to shutdown the pi nicely? I assume so to avoid the traditional filesystem issues…
how do I shutdown the pi nicely from a container?
Some more information on this in the docs would be really useful, surely it’s quite a common thing to do? And make fin-block much more discoverable, took me ages to find it, lots of old links to it are broke. Or document a simpler alternative if one exists. IFor someone who has never used docker/containers before it was quite a stumbling block having to figure out how multi-container development works, figure out docker-compose.yml files (no simple examples easily found) etc just so I can sleep the device for a time.
Hmm well I have the shutdown command working, but it doesn’t appear to be waking up again.
The shutdown command: is that shutting down:
a) just the pi’s host OS?
b) the full balena fin board including the co-processor?
i.e. will issuing the API shutdown command allow the sleep to wake up again? and will the services all start again? At this point it shuts down as expected, then lights come back on, but services never start.
I’m issuing the following commands:
os.system('curl -v POST localhost:1337/sleep --data \'{{"sleepTime" : {},"sleepDelay" : 30}}\' --header "Content-Type: application/json"'.format(interval));
os.system('curl -X POST --header "Content-Type:application/json" "{}/v1/shutdown?apikey={}"'.format(BALENA_SUPERVISOR_ADDRESS, BALENA_SUPERVISOR_API_KEY))
The shutdown command is just that, shut down everything gracefully, so you can remove power.
Wake up is not included in it.
If you want to reboot the device, there’s a separate command for that. Stopping and starting containers are their own commands as well.
In all cases, your containers should come back up when your host OS boots again.
I have no experience with the fin-block and its implementation of the sleep function.
I might be able to experiment a little with it somewhere this week though.
The host OS should be pretty well designed against data corruption, so I think the main question is how your containers behave.
Hey thanks for the reply - yeah I was wondering if shutting down my containers would be enough. But I’m assuming we could still corrupt the filesystem in the parent system.
Restart wouldn’t be a good idea because it’ll be re-booting when the pi power is cut.
From what I understand, the fin-block container provides a simple http accessible API to the co-processor functions. The sleep function in particular tells the FIN board co-processor to wake up at a certain time, and the pi, modem and all ports are shutdown.
Cheers
Hi yes I’m using the fin block container sleep command, which shuts down the device as expected, but still not 100% clear if it is shutting down the host OS cleanly. I suspect it is. I hope it is I can’t figure out how to issue a Host OS shutdown command from a container after I’ve told the fin block container to shutdown in X seconds. I just saw the message from @rahul-thakoor I couldn’t see a sleep command listed in the API docs when I looked months ago. And still nothing there:
Is that /sleep command you give for fin block? or the balena API?
I also have the occasional device that shuts down and won’t wake up again without a hard power off/on. Hard to diagnose what’s going on as they are out in the field, but I’m sure I saw one with lights on the device still, so it’s like it tried to shutdown, the logs say it did a shutdown, but didn’t actually shut all the way down and is stuck. Or it’s stuck coming back on. Not sure.
I guess my problem is I’m not sure if I’m using the fin block sleep command correctly. There’s very few examples of using this sleep mode online. Also in the logs it mentions looking for updates of the fin block firmware which I don’t understand, I wonder if it freezes sometimes when this happens? Should firmware updates be turned off in production? I don’t know.
Any ideas still welcome. We are waiting on some replacement boards arriving any day now, then I can do more testing.
As far as i know the device Compute Module that runs on the fin is shut down. And the co-processor is managing the shutdown/sleeping time. You can check the power usage meanwhile is sleeping. You can read more here.
Thanks for your feedback and i will see if someone from the balenaFin team can give you more insights about your questions.
You don’t have to bother calling the supervisor directly, as long as your fin-block has the supervisor-api capability in the docker-compose.yml file (template here ), you should be safe only using the /sleep command.