Prioritizing service order¶
Although systemd can start services in parallel, you can optimize service ordering by adjusting the dependency parameters in service unit files so that certain services will wait on other services to start before loading themselves. In this procedure, for example, you will create Quadlet unit files for the engine and radio services to configure their respective boot order.
Prerequisites
- Automotive Image Builder tool is installed and enabled.
- QEMU is installed.
Procedure
-
Create Quadlet unit files for the
radio-serviceandengine-serviceservices in your sample applicationauto-apps:engine.container file[Unit] Description=Demo engine service container # routingmanagerd.socket is not included in vsomeip3 3.5.11, so let's use routingmanagerd.service for now Requires=routingmanagerd.service After=routingmanagerd.service [Container] Image=localhost/auto-apps Exec=/usr/bin/engine-service Volume=/run/vsomeip:/run/vsomeip [Service] Restart=always [Install] WantedBy=multi-user.targetNote
Requires=routingmanagerd.socketis a hard dependency that prevents the engine service from starting until the UNIX socket file is active.After=routingmanagerd.socketis an ordering dependency that indicates the engine service can start only after the activation of the socket file.radio.container file[Unit] Description=Demo radio service container # routingmanagerd.socket is not included in vsomeip3 3.5.11, so let's use routingmanagerd.service for now Requires=routingmanagerd.service After=routingmanagerd.service Wants=engine.service [Container] Image=localhost/auto-apps Exec=/usr/bin/radio-service Volume=/run/vsomeip:/run/vsomeip [Service] Restart=always [Install] WantedBy=multi-user.targetNote
Requires=routingmanagerd.socketis a hard dependency that prevents the radio service from starting until the UNIX socket file is active.Wants=engine.serviceis a soft dependency. Ideally, the engine service activates the radio service, but if the engine service isn’t activated, systemd still permits the radio service to start. -
Create an Automotive Image Builder manifest named
quadlet_radio_engine.aib.ymlthat contains the following code, which copies the Quadlet unit files to the/etc/containers/systemd/directory during the build process:Manifest configuration to copy Quadlet unit files# Example manifest building an image with, pre-installed, a container image # hosted in a remote container registry name: quadlet_radio_engine content: repos: - id: copr-sample-apps baseurl: https://download.copr.fedorainfracloud.org/results/alexl/cs9-sample-images/centos-stream-9-$arch/ rpms: - podman - containernetworking-plugins - vsomeip3-routingmanager - dlt-daemon # For testing the image only: - openssh-server - openssh-clients container_images: # Get the auto-apps container image from gitlab - source: registry.gitlab.com/centos/automotive/sample-images/demo/auto-apps tag: latest name: localhost/auto-apps add_files: - path: /etc/containers/systemd/radio.container source_path: ../radio.container - path: /etc/containers/systemd/engine.container source_path: ../engine.container # Required for testing the image only: systemd: enabled_services: # Enable ssh daemon - sshd.service # Enable the dlt daemon - dlt auth: # "password" root_password: $6$xoLqEUz0cGGJRx01$H3H/bFm0myJPULNMtbSsOFd/2BnHqHkMD92Sfxd.EKM9hXTWSmELG8cf205l6dktomuTcgKGGtGDgtvHVXSWU. # Required for testing the image only: sshd_config: PasswordAuthentication: true PermitRootLogin: trueNote
The
path:option resolves a relative path. In this example, your Quadlet unit files are in the../directory. -
Run the
automotive-image-buildertool to build an OS image:Important
This documentation is in the process of being adjusted for the changes implemented in Automotive Image Builder 1.1.4. In the meantime, to keep the sample commands in this documentation valid, you must use the deprecated CLI, as shown in this example.
-
Verify that the script has created an AutoSD image file named
quadlet_radio_engine.qcow2in your present working directory. -
Run the image:
-
After the image boots, log in to the VM with the user name
rootand the passwordpassword. -
From the VM, confirm the engine service started:
-
List the dependencies for the engine service. The solid dot (●) to the left of
routingmanagerd.socketindicates that the service, whichengine.servicerequires to start, is active: -
Confirm the radio service started:
-
List the dependencies for the radio service. The solid dot (●) to the left of
engine.serviceindicates that the engine service is active: