YAML-driven ROS2 systemd service manager
Project description
ROS2 Systemd Manager
ROS2 Systemd Manager is a YAML-driven tool to manage ROS2 launch tasks as systemd services.
What It Does
- Bootstrap local files with
ros2-systemd-manager init - Install units with
install - Install + start + enable with
apply - Remove units with
uninstall - Run synchronized update flow with stale-unit cleanup via
update - Regenerate Makefile only with
makefile - Upgrade tool to latest version via
upgrade
Installation
Note: This tool is designed for Linux systems with systemd. Ensure you have Python 3 and pip installed. It is recommended to use sudo for installation to allow systemd unit management.
sudo pip install ros2-systemd-manager
CLI
ros2-systemd-manager [-v] [-c CONFIG] [-w WORKSPACE_KEY] [-f] [action]
Supported actions:
initinstallapplyuninstallupdatemakefileupgrade
Init Output
Run in your desired config directory (e.g., ROS2 workspace root) to generate the default YAML config and Makefile targets:
ros2-systemd-manager init
Generated files:
./ros2_services.yaml(default configuration)./ros2-systemd-manager.mk(generated makefile targets fragment)./Makefile(entrypoint that includes the.mkfile)
Note: The tool places generated makefile targets into
ros2-systemd-manager.mkto keep your rootMakefileclean. The rootMakefilewill automatically include the.mkfragment.
YAML Keys
Required:
systemdruntimeworkspaces
Optional:
actions(default action isapply)makefile
Example YAML Configuration
Below is a sample ros2_services.yaml demonstrating common fields and layout.
systemd:
unit_dir: /etc/systemd/system
wanted_by: multi-user.target
runtime:
user: user
group: user
home: /home/user
shell: /bin/bash
restart: on-failure
restart_sec: 3
workspaces:
default_ws: # Workspace key, selectable via --workspace-key
path: /home/user/default_ws
setup_script: install/setup.bash
services:
- unit_name: ros2-foxglove-bridge.service
description: ROS2 Foxglove Bridge
use_root: false # Optional: default false. When true, force this service to run as root.
launch_command: ros2 launch foxglove_bridge foxglove_bridge_launch.xml
- unit_name: ros2-soem-bringup.service
description: ROS2 Simple Open EtherCAT Master Bringup (https://github.com/AIMEtherCAT/EcatV2_Master)
use_root: false
service_options: # Example of granting specific capabilities to a service without running as root
- CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN
- AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN
launch_command: ros2 launch soem_bringup bringup.launch.py
- unit_name: ros2-infantry-chassis.service
description: ROS2 Infantry Chassis Controller
depends_on:
- ros2-soem-bringup.service
launch_command: ros2 launch infantry_controller infantry_chassis.launch.py
- unit_name: ros2-sp-vision-autoaim.service
description: TongjiSuperPower/sp_vision_25 Auto Aim (via self defined sp_vision_launch)
service_options:
- CPUAffinity=1 2 3 # Example of setting CPU affinity for a service
launch_command: ros2 launch sp_vision_launch sp_vision.launch.py config:=sentry.yaml
This example shows how to define:
systemdsettings for unit placement and installation behaviorruntimedefaults shared by all services- one or more
workspaces, each with its ownserviceslist depends_onrelationships between services- optional
service_optionsfor extra systemd directives
Generated Makefile
Note: The generated Makefile targets are designed to be intuitive and cover common systemd management tasks. You can customize the generated targets by modifying the
workspacessection in your YAML config.
Primary targets:
make upgrade # self-upgrade ros2-systemd-manager via pip
make install # install unit files only
make apply # install + start + enable
make start # systemctl start all configured units
make stop # systemctl stop all configured units
make restart # systemctl restart all configured units
make status # systemctl status all configured units
make status-long # systemctl status with 100 log lines
make enable # systemctl enable all configured units
make disable # systemctl disable all configured units
make logs # follow logs for all configured units
make logs-recent # show last 200 log lines for all configured units
make <op>-<service> # op in start/stop/restart/status/enable/disable/logs
make <op>-<service>-<sfx> # e.g., logs-<svc>-recent, status-<svc>-long (100 lines)
make uninstall # uninstall all configured units
make update # stop old + uninstall + install/start/enable + refresh mk
make makefile # refresh generated mk only (no systemd changes)
Config behavior:
- No hardcoded absolute config path.
- Default auto-discovery strictly looks for
./ros2_services.yamlin the current running directory. - Override manually via
CONFIGenvironment variable or--configparameter:
# Using Makefile with custom config
make apply CONFIG=./my_services.yaml
# or
ros2-systemd-manager apply --config ./my_services.yaml
File Tracking & Safety
- Automatic Backups: Whenever files in
/etc/systemd/system/are modified (viaupdate,install, oruninstall), a copy of the exact deployed file along with its MD5 hash (and a global hash) is stored in~/.config/ros2-systemd-manager/previous-update/. - Modification Detection: During
updateoruninstalloperations, the manager usesfilecmpanddiffto check if you have manually modified the systemd service file. If modifications are detected, it presents a diff in the terminal and asks if you want to archive your manual changes to~/.config/ros2-systemd-manager/archive/before proceeding with the overwrite/deletion.
Safety
- Use trusted launch commands only.
- Validate workspace paths and setup scripts before
applyorupdate. - Prefer
installfirst for new services.
Contributing
Licensed under the Apache License 2.0. See LICENSE for details.
Contributions are welcome! Please open issues or submit pull requests for bug fixes, improvements, or new features.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ros2_systemd_manager-0.1.4.tar.gz.
File metadata
- Download URL: ros2_systemd_manager-0.1.4.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e1be35a19954dcf2fbdb0eb2ac1621fba1fe21619a6ca9a2a2d4236b08155db
|
|
| MD5 |
7745c58e39398f4ec0bb90d30cf82738
|
|
| BLAKE2b-256 |
5117e86a6d8818a11c63a274b77ffa18cd4db46a0f5010dfb9033eec93949937
|
Provenance
The following attestation bundles were made for ros2_systemd_manager-0.1.4.tar.gz:
Publisher:
release-pypi.yml on hnrobert/ros2-systemd-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ros2_systemd_manager-0.1.4.tar.gz -
Subject digest:
8e1be35a19954dcf2fbdb0eb2ac1621fba1fe21619a6ca9a2a2d4236b08155db - Sigstore transparency entry: 1340358722
- Sigstore integration time:
-
Permalink:
hnrobert/ros2-systemd-manager@6bf19b7c386afdb4cd517578c100040852acf827 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hnrobert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@6bf19b7c386afdb4cd517578c100040852acf827 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file ros2_systemd_manager-0.1.4-py3-none-any.whl.
File metadata
- Download URL: ros2_systemd_manager-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d73e1db21be6a6564094864341ffbb428e050fc0ebc229310883ff705a95e469
|
|
| MD5 |
aaa7c358221b9f7726d11437f8ba33ab
|
|
| BLAKE2b-256 |
a0a96b0dfeb6ba0f0266ddd1aa818cdc10bf01bf1ede38b234e722c2842d045d
|
Provenance
The following attestation bundles were made for ros2_systemd_manager-0.1.4-py3-none-any.whl:
Publisher:
release-pypi.yml on hnrobert/ros2-systemd-manager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ros2_systemd_manager-0.1.4-py3-none-any.whl -
Subject digest:
d73e1db21be6a6564094864341ffbb428e050fc0ebc229310883ff705a95e469 - Sigstore transparency entry: 1340358743
- Sigstore integration time:
-
Permalink:
hnrobert/ros2-systemd-manager@6bf19b7c386afdb4cd517578c100040852acf827 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/hnrobert
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-pypi.yml@6bf19b7c386afdb4cd517578c100040852acf827 -
Trigger Event:
workflow_dispatch
-
Statement type: