Hi,
We’re trying to achieve a similar behavior (slightly different):
We have an service that records large volumes of data and also generates console output. We have a control service that starts/stops the main service (via the supervisor) when the user requests it. Due to the data volume, we don’t want the service to start recording immediately on reboot or when we update the device to a new release. In order for the console output to be captured in the device logs, we need to run the application as the CMD
in its container, but doing that also causes it to run every time the container starts, including reboot/update.
Ideally we’d like the ability to flag the main service to not start automatically, but there doesn’t seem to be a way to do that currently. We looked at using an environment variable as suggested on another thread
(Selectively running containers on a device) to flag a “stop on reboot” condition. The idea would be to have a service that comes up on boot and sets a persistent “stop automatically” environment variable on the main service, and then the have the main service depend on the flag service so it is started second, and have it clear the flag after it skips its first startup. Unfortunately, there doesn’t seem to be a way to set persistent environment variables from within a container without access to the Balena backend/CLI.
Any suggestions?
Thanks,
Adam