Automatically restarting Open Balena after reboot

There is a thread on GitHub around the automatic restart behaviour of Open Balena (https://github.com/balena-io/open-balena/issues/83), but it seems for the executing the startup script (’/scripts/compose up’) an init system will be used. I was surprised not to see a systemd service script for this.

Here is what I am looking to use, would be good to clarify whether there is an alternative already provided somewhere, or any comments on the below:

[Unit]
Description=Start OpenBalena
After=docker.service
BindsTo=docker.service
ReloadPropagatedFrom=docker.service

[Service]
Type=simple
User=balena
ExecStart=/home/balena/open-balena/scripts/compose up
ExecStop=/home/balena/open-balena/scripts/compose stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

Hello @maggie OpenBalena is designed to be a flexible solution for users and as a result we do not tie ourselves to a particular init system. This allows users to choose a start-up method that works best for their needs. In this case you are welcome to either add restart: always to the docker compose file or use a systemd script as you wish. We also find that not restarting OpenBalena by default is very useful during development and debugging as the logs are preserved.

For anyone drawing on this, suggest including a timeout not included in the initial post:

[Unit]
Description=Start OpenBalena
After=docker.service
BindsTo=docker.service
ReloadPropagatedFrom=docker.service

[Service]
Type=simple
User=balena
ExecStart=/home/balena/open-balena/scripts/compose up
ExecStop=/home/balena/open-balena/scripts/compose stop
TimeoutStopSec=120
Restart=on-failure

[Install]
WantedBy=multi-user.target