Skip to content

Lifecycle Backends

Oleksandr Geronime edited this page Jun 27, 2026 · 1 revision

Lifecycle Backends

Lifecycle backends are serpgen plugins that generate supervisor and init configurations for managing SERP processes. When serpgen generate-workspace runs, it generates the lifecycle config for each process according to the launcher field on its domain.

Configuring a Lifecycle Backend

Set launcher in the domain configuration inside a deployment spec:

domains:
  service:
    launcher: systemd   # systemd | initd | android_init | script
    install:
      prefix: /opt/myapp
      user: myapp
      group: myapp
    restart_policy: on-failure

systemd (serp_lifecycle_systemd)

Generates .service unit files. The standard choice for modern embedded Linux.

Generated output (gen/deployments/<deployment>/lifecycle/<process>.service):

[Unit]
Description=ClimateHal process
After=dbus.service

[Service]
Type=simple
ExecStart=/opt/myapp/bin/climate_hal_app
User=myapp
Group=myapp
Restart=on-failure
RestartSec=2

[Install]
WantedBy=multi-user.target

Process ordering from start_after in the deployment spec is translated to After= directives in the unit file.

Installation:

sudo cp gen/deployments/multiprocess_dbus/lifecycle/*.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now climate_hal_app

Use for: Linux with systemd — most modern embedded Linux distributions, automotive-grade Linux (AGL), Yocto-based systems.

init.d (serp_lifecycle_initd)

Generates traditional SysVinit shell scripts under /etc/init.d/. No systemd dependency.

Generated output: A shell script per process with start, stop, restart, and status commands following the LSB init script convention.

Use for: Older embedded Linux targets that predate systemd, or distributions that explicitly use SysVinit.

Android Init (serp_lifecycle_android_init)

Generates .rc files for the Android Init system. The Android Init language is the standard process management mechanism on Android and Android Automotive OS.

Generated output (gen/deployments/<deployment>/lifecycle/<process>.rc):

service climate_hal_app /opt/myapp/bin/climate_hal_app
    class main
    user myapp
    group myapp
    restart_period 2

Use for: AAOS (Android Automotive OS) targets. The .rc files are placed into the Android build system as part of the system image.

script (launcher: script)

Generates simple shell start/stop scripts with no OS-level supervisor dependency. Processes are started directly and managed by the script, not by systemd or init.

Use for:

  • macOS development (systemd is not available)
  • Quick iteration and debugging
  • Environments where a supervisor is not desired or available

The generated script handles process ordering based on start_after by waiting for each dependency process to be ready before starting the next.

Deployment Spec Reference

domains:
  service:
    launcher: systemd           # Which backend to use
    install:
      prefix: /opt/myapp        # Binary installation prefix
      user: myapp               # OS user to run the process as
      group: myapp              # OS group
    restart_policy: on-failure  # Restart behavior hint passed to the backend
    logging:
      strategies: [file]
      file_dir: /var/log/myapp
      file_rotation_size_mb: 10
      file_rotation_count: 5
  
  hmi_session:
    launcher: script
    logging:
      strategies: [console, file]

launcher Values

Value Plugin Platform
systemd serp_lifecycle_systemd Linux with systemd
initd serp_lifecycle_initd Linux with SysVinit
android_init serp_lifecycle_android_init AAOS / Android
script Built-in macOS, Linux (development)

restart_policy

Passed through to the generated supervisor config. Common values:

Value Behavior
on-failure Restart the process only if it exits with a non-zero status
always Always restart regardless of exit code
no Do not restart

Related Pages

Clone this wiki locally