Skip to content

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

Procedure

  1. Create Quadlet unit files for the radio-service and engine-service services in your sample application auto-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.target
    

    Note

    Requires=routingmanagerd.socket is a hard dependency that prevents the engine service from starting until the UNIX socket file is active. After=routingmanagerd.socket is 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.target
    

    Note

    Requires=routingmanagerd.socket is a hard dependency that prevents the radio service from starting until the UNIX socket file is active. Wants=engine.service is 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.

  2. Create an Automotive Image Builder manifest named quadlet_radio_engine.aib.yml that 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: true
    

    Note

    The path: option resolves a relative path. In this example, your Quadlet unit files are in the ../ directory.

  3. Run the automotive-image-builder tool 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.

    $ sudo aib-dev build-deprecated \
    --distro autosd9 \
    --target qemu \
    --mode image \
    --build-dir=_build \
    --export qcow2 quadlet_radio_engine.aib.yml \
    quadlet_radio_engine.qcow2
    
  4. Verify that the script has created an AutoSD image file named quadlet_radio_engine.qcow2 in your present working directory.

  5. Run the image:

    $ sudo automotive-image-runner quadlet_radio_engine.qcow2
    
  6. After the image boots, log in to the VM with the user name root and the password password.

  7. From the VM, confirm the engine service started:

    # systemctl status engine.service
    ● engine.service - Demo engine service container
        Loaded: loaded (/etc/containers/systemd/engine.container; generated)
        Active: active (running) since Mon 2025-09-08 19:40:33 UTC; 7min ago
    ...
    
  8. List the dependencies for the engine service. The solid dot (●) to the left of routingmanagerd.socket indicates that the service, which engine.service requires to start, is active:

    # systemctl list-dependencies engine.service
    engine.service
    ● ├─routingmanagerd.socket
    ● ├─system.slice
    ● ├─network-online.target
    ○ │ └─NetworkManager-wait-online.service
    ● └─sysinit.target
    ...
    
  9. Confirm the radio service started:

    # systemctl status radio.service
    ● radio.service - Demo radio service container
        Loaded: loaded (/etc/containers/systemd/radio.container; generated)
        Active: active (running) since Mon 2025-09-08 19:40:33 UTC; 28s ago
     ...
    
  10. List the dependencies for the radio service. The solid dot (●) to the left of engine.service indicates that the engine service is active:

    # systemctl list-dependencies radio.service
    radio.service
    ● ├─engine.service
    ● ├─routingmanagerd.socket
    ● ├─system.slice
    ● ├─network-online.target
    ○ │ └─NetworkManager-wait-online.service
    ● └─sysinit.target
    ...
    

© Red Hat