Skip to content

Instantly share code, notes, and snippets.

@reubenmiller
Created August 21, 2025 13:15
Show Gist options
  • Select an option

  • Save reubenmiller/c082926144f8efb7fc46e1623e3472f8 to your computer and use it in GitHub Desktop.

Select an option

Save reubenmiller/c082926144f8efb7fc46e1623e3472f8 to your computer and use it in GitHub Desktop.
thin-edge.io running multiple tedge-agent instances on a single device

Running a new tedge-agent instance to manage a child device

  1. Create systemd service template definition

    cat <<EOT > /lib/systemd/system/[email protected] 
    [Unit]
    Description=tedge-agent (device/%i//) is a thin-edge.io component to support operations.
    After=syslog.target network.target mosquitto.service
    
    [Service]
    User=tedge
    EnvironmentFile=-/etc/agents/%i/env
    
    Environment=TEDGE_RUN_LOCK_FILES=false
    Environment=TEDGE_CONFIG_DIR=/etc/agents/%i
    Environment=TEDGE_AGENT_STATE_PATH=/data/tedge-%i
    RuntimeDirectory=tedge-agent-%i
    ExecStartPre=+-/usr/bin/tedge init
    ExecStart=/usr/bin/tedge-agent --mqtt-device-topic-id "device/%i//"
    Restart=on-failure
    RestartPreventExitStatus=255
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target
    EOT
  2. Create a new service from the systemd service template

    systemctl enable --now [email protected]

    Where the string after the @ sign is used in the topic prefix, e.g. device/<name>//

  3. Check that the service is running

    systemctl status [email protected]
  4. Add any agent specific files under the relevant sub folder (which is created when the service is started)

    ls -l /etc/agents/<name>
    
    # e.g.
    ls -l /etc/agents/proxy-child01
  5. Check in Cumulocity that the new child device (represented by the new tedge-agent service) is visible

  6. You can then add tedge-agent workflows under the following folder

    ls -l /etc/agents/<name>/operations/
    
    # e.g.
    ls -l /etc/agents/proxy-child01/operations/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment