Skip to main content
Version: scarthgap_2-x

Service Wrappers

This page explains the purpose, structure, and integration of service wrappers in the Clea Cloud IoT architecture.


What Are Service Wrappers?

Service wrappers are Yocto recipes and supporting files that install, configure, and manage the main IoT applications (such as Edgehog Device Runtime and Astarte Message Hub) as systemd services on the target device. They ensure that these applications are started automatically at boot, monitored, and restarted if necessary.


Why Use Service Wrappers?

  • Automated Startup:
    Ensures critical services are started at boot without manual intervention.
  • Reliability:
    Leverages systemd to monitor and restart services if they fail.
  • Separation of Concerns:
    Keeps application packaging and service management logic distinct.
  • Configurability:
    Allows for custom wrapper scripts or environment setup before launching the main binary.

Typical Structure

A service wrapper recipe directory (e.g., recipes-iot/service-edgehog-device-runtime/) usually contains:

  • A .bb BitBake recipe file (e.g., service-edgehog-device-runtime.bb)
  • A systemd unit file (e.g., edgehog-device-runtime.service)
  • Optional wrapper scripts or configuration files

Example: Systemd Unit File

A typical systemd unit file for Edgehog Device Runtime:

[Unit]
Description=Edgehog Device Runtime
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/edgehog-device-runtime
Restart=on-failure

[Install]
WantedBy=multi-user.target

How Service Wrappers Work

  1. Installation:
    The Yocto recipe installs the systemd unit file and any required scripts to the appropriate locations in the root filesystem.
  2. Enablement:
    The service is enabled so it starts automatically at boot (systemctl enable ...).
  3. Management:
    Systemd manages the lifecycle of the service, handling restarts and logging.

Example Recipes


Customization

Service wrappers can be extended to:

  • Add environment files or configuration
  • Use wrapper scripts to set up prerequisites before launching the main binary
  • Add dependencies on other services (e.g., networking)

Summary Table

Service Wrapper RecipeMain Service ManagedRole
service-edgehog-device-runtime.bbEdgehog Device RuntimeDevice management and telemetry
service-astarte-message-hub.bbAstarte Message HubD-Bus to Astarte bridge

References