How to prepare your target platform to auto-boot a Storyboard application with Linux systemd

Once you have configured your Linux target platform with the appropriate Storyboard runtime engine and successfully deployed and tested your Storyboard application (.gapp) file with associated graphical assets,scripts and fonts you are now ready to have this auto-boot directly into the application at power-on.

Most recent core Linux BSPs are now based on systemd which is a replacement to the older traditional "System V init" system. Here systemd stands for "system daemon".

With systemd the runlevels are well defined and allow for better handling of initialisation sequence dependencies which gives the platform the ability to handle more work in parallel at system start-up.  In most Storyboard based systems the Linux environment does not need to first run a desktop environment.

Setting-up the runtime display environment

If a full desktop distribution is used by default it will likely be necessary to disable the window manager if you want to transition to more of a turn-key user experience. Assuming your distribution window manager uses systemd, then systemd's default target is likely graphical.target.

You can determine which run-level your platform is configured for using the following command:

sudo systemctl get-default

You can change the default to multi-user.target and console mode with (reboot to take effect):

sudo systemctl set-default multi-user.target

You can change the default back to desktop mode with (reboot to take effect):

sudo systemctl set-default graphical.target

Defining the Storyboard Launcher Service

The systemd environment uses a service definition to manage the position in the start-up sequence, and example of  which is shown below. This simply calls a Storyboard start-up script storyboard_launcher.sh to kick-off the Storyboard sbengine process as you would from the command line.

Note that it is registered as having a dependency to start after multi-user.target which is the first availability base login for the console user - 'root' in this case:

storyboard_launcher.service

[Unit]

Description=Storyboard Launcher Service

After=multi-user.target

[Service]

Type=idle

User=root

ExecStart=/home/root/Crank/storyboard_launcher.sh

Restart=on-failure

RestartSec=0

[Install]

WantedBy=multi-user.target

Installing the Storyboard Launcher Service

This service definition file needs to be registered with systemd so it first needs to be positioned in the correct filesystem fiolder (normally /lib/systemd/system):

sudo cp storyboard_launcher.service /lib/systemd/system

We then need to tell systemd to recognize our service, so enter:

sudo systemctl daemon-reload

Note: You will need to enter this command every time you change your .service file, as systemd needs to know it has been updated.

We then need to tell systemd that we want our service to start on boot, so enter:

sudo systemctl enable storyboard_launcher.service

This will create a symbolic link from the system’s copy of the service file (usually in /lib/systemd/system or /etc/systemd/system) into the location on disk where systemd looks for auto-start files,  usually /etc/systemd/system/some_target.target.wants

To disable the service from starting automatically, you can type:

sudo systemctl disable storyboard_launcher.service

This will remove the symbolic link that indicated that the service should be started automatically however note that started enabling (or disabling) a service does not take effect it in the current session. It should take effect when you next reboot.

Checking the Status of Services

To check the status of the service on your system, you can use the status command:

systemctl status storyboard_launcher.service

This will provide you with the service state, the cgroup hierarchy, and the first few log lines which can be useful to help debug if the application does not start as expected.

Was this article helpful?
0 out of 1 found this helpful