I have a simple application which just waits for a button to be pressed on a GPIO pin, then set two GPIO pins high for 6 seconds, and then repeat.
I’ve noticed that two instances of my application must be running, because both pins go high whenever one should be, but when I kill the application from the dashboard, the button still causes the pins to change appropriately. I’ve been going in and out of local mode, is it possible a local mode instance of my application is running in a container? How would I see this and kill it?
Hi,
Thanks for bringing this up.
I was able to reproduce this on my side and have opened an internal ticket to improve the current state.
By SSHing to the HostOS and running balena ps after disabling local mode from the dashboard, I was seeing a local-app container still running.
What version of the OS & supervisor are you using?
We are currently revamping our local mode implementation, which will also support local mode development of multicontainer applications.
If your device is running balenaOS v2.26.0+ you should be able to use local mode with the balena push <device_ip> command., which is supported in the latest CLI version. With balena push you should no longer face the leftover local-app container issue.
Let me point you to the respective documentation page of the CLI:
Is there a way to set environment variables with this command?
I was able to do that with -e in balena local push, though I noticed also that when I did it there it would only save any variables the first time I ran a command with -e, and I would need to remove the sync file when I wanted to change variables. Note that changing the variable in the sync file didn’t seem to cause any update either.
Also it would be nice if it could handle mdns addresses…
I should be running the latest everything:
Host OS: 2.29.0+rev1
Supervisor: 9.0.1
balena-cli: 9.6.0
we plan to eventually add support for setting the environment variables via local push, its on our radar but not supported yet. In the meantime, the best way would be to declare your env vars directly in your docker-compose file.
Just so you know, it seems this same thing happens in other contexts as well, for example, I reverted to using local push but the container which I pushd by local-ip still runs whenever I restart, until I manually removed it in the host OS.
The container which I pushed with balena push <deviceIp> still runs after device restart, alongside balena local push <deviceIp> devices.
Its as though things which are pushed using balena push or git push balena are fully isolated from things which are balena local pushd.
The relationship is symmetric, as the local containers continue running after pushing via a non-local method, and the non-local containers continue running after pushing via the local method.
Could you please only use balena push <Device_IP> instead of balena local push <Device_IP>?
Since the version OS 2.29 (which you are using), balena push <Device_IP> provides the desired behaviour. The previous versions have not supported such behaviour. The new balena push workflow now supports multicontainer and the containers will be cleared when the device is switched out of local mode.
We still need to update our documentation about it. Sorry about the confusion.