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
- Podman is installed.
- The
automotive-image-buildertool is installed. - QEMU is installed.
Procedure
-
Create a systemd socket unit and 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 Volume=/run/root-ipc-demo:/run/root-ipc-demo [Service] Restart=always [Install] WantedBy=multi-user.targetNote
Requires=routingmanagerd.serviceis a hard dependency that prevents the engine service from starting until the routing manager service is active.After=routingmanagerd.serviceis an ordering dependency: the engine service starts only after the routing manager service has started.radio.socket file[Unit] Description=example systemd unix socket [Socket] ListenStream=%t/root-ipc-demo/root_ipc.socket RuntimeDirectory=root-ipc-demo [Install] WantedBy=sockets.targetradio.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 Requires=radio.socket After=radio.socket Wants=engine.service [Container] Image=localhost/auto-apps Exec=/usr/bin/radio-service Volume=/run/vsomeip:/run/vsomeip Volume=/run/root-ipc-demo:/run/root-ipc-demo [Service] Restart=always [Install] WantedBy=multi-user.targetNote
Requires=radio.socketis a hard dependency that prevents the radio service from starting until the socket unit is active.After=radio.socketis an ordering dependency: the radio service starts only after the socket unit has started.Requires=routingmanagerd.serviceis a hard dependency that prevents the radio service from starting until the routing manager service is active.Wants=engine.serviceis a soft dependency. Ideally, the engine service activates the radio service, but if the engine service is not activated, systemd still permits the radio service to start. -
Create an Automotive Image Builder manifest named
root-root.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# root-root IPC communications demo name: root-root-IPC-communications content: repos: - id: epel metalink: https://mirrors.fedoraproject.org/metalink?repo=epel-10&arch=$arch rpms: - podman - netavark - aardvark-dns - 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 - path: /etc/systemd/system/radio.socket source_path: ./radio.socket # Required for testing the image only: systemd: enabled_services: # Enable ssh daemon - sshd.service # Enable the dlt daemon - dlt # Enable the IPC socket - radio.socket 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
aib-dev buildto build a disk image: -
Verify that the script has created an AutoSD image file named
root-root.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.serviceindicates 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: