Colcon plugin that generates systemd service units for opted-in packages during colcon build
Project description
colcon-systemd
Colcon plugin that generates systemd service units for opted-in packages during
colcon build, installable with pip install.
Installation
From PyPI (once published)
Install into your current Python environment (the same one where colcon is
installed):
pip install colcon-systemd
This installs the plugin into your user or virtualenv site-packages — it does not install anything system-wide or require root. colcon discovers the plugin automatically via entry points.
From Source (development)
git clone https://github.com/CraigBuilds/colcon-systemd.git
cd colcon-systemd
pip install -e ".[test]"
The -e (editable) flag means changes you make to the source take effect
immediately without reinstalling. Run this from the cloned colcon-systemd/
directory.
Verifying the Installation
After installing, confirm colcon can see the plugin:
colcon build --event-handlers systemd+
# You should not get "unknown event handler" errors
Quick Start
1. Add a Config File to Your Package
In the source root of a ROS 2 / colcon package (next to package.xml), create
a colcon-systemd.yaml:
services:
- name: my_node
entry_point: my_node # console_scripts entry point name
description: "My ROS 2 node"
environment:
ROS_DOMAIN_ID: "0"
restart: on-failure
2. Build from Your Workspace Root
Run colcon build from the workspace root (the directory that contains
src/, or wherever your packages live — the same place you'd normally run
colcon build):
cd ~/my_ros2_ws # your colcon workspace root
colcon build
The plugin runs automatically for any package that contains a
colcon-systemd.yaml file. Packages without the file are unaffected.
3. Find the Generated Files
The generated service files are written into the colcon install tree — they
are never written to /etc/systemd/system or any system directory:
install/<pkg>/share/colcon-systemd/my_node.service # systemd unit
install/<pkg>/share/colcon-systemd/my_node.sh # wrapper script
4. Activate the Service (Optional)
To actually run the service with systemd, symlink the unit into your user systemd directory:
mkdir -p ~/.config/systemd/user
ln -s "$(pwd)/install/<pkg>/share/colcon-systemd/my_node.service" \
~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user start my_node
systemctl --user status my_node
This uses systemctl --user, which does not require root.
Configuration Reference
Each service in colcon-systemd.yaml accepts:
| Field | Required | Default | Description |
|---|---|---|---|
name |
Yes | — | Service name (alphanumeric, hyphens, underscores) |
entry_point |
One of entry_point/executable | — | console_scripts entry point name |
executable |
One of entry_point/executable | — | Executable name |
description |
No | <pkg> <name> |
systemd unit description |
after |
No | [network.target] |
systemd After= dependencies |
environment |
No | {} |
Environment variables |
restart |
No | on-failure |
systemd restart policy |
working_directory |
No | — | Working directory for the service |
How It Works
colcon-systemd registers as a colcon event handler extension. During
colcon build, it listens for successful build completions (JobEnded events
with rc == 0). For each package that has a colcon-systemd.yaml file, it:
- Parses and validates the configuration
- Generates a bash wrapper script that sources
setup.bashandexecs the entry point - Generates a systemd
.serviceunit file that runs the wrapper script
This approach uses direct execution of the installed entry point rather
than ros2 run, for simpler signal handling and no runtime dependency on the
ros2 CLI. See DESIGN.md for detailed rationale.
Supported Package Types
| Type | Support |
|---|---|
ros.ament_python |
Primary (best tested) |
python |
Full |
ros.ament_cmake |
Full |
cmake |
Full |
ros.catkin |
Full |
Other types generate a warning but still produce units.
Disabling the Extension
colcon build --event-handlers systemd-
Testing
pip install -e ".[test]"
pytest tests/ -v
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
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 colcon_systemd-0.1.0.tar.gz.
File metadata
- Download URL: colcon_systemd-0.1.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cce4ccd38f57a1a4c4f6fce0a580fed83f98dcc38182cc0fe0f82c7c35a2fa8
|
|
| MD5 |
64f4ddbeb03f44b7077f929b26810e57
|
|
| BLAKE2b-256 |
ba2f01049bbbeb2da997c58dbc26847052cfc7e30511a87f275c6956a33c7dc3
|
Provenance
The following attestation bundles were made for colcon_systemd-0.1.0.tar.gz:
Publisher:
release.yml on CraigBuilds/colcon-systemd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colcon_systemd-0.1.0.tar.gz -
Subject digest:
9cce4ccd38f57a1a4c4f6fce0a580fed83f98dcc38182cc0fe0f82c7c35a2fa8 - Sigstore transparency entry: 1181325726
- Sigstore integration time:
-
Permalink:
CraigBuilds/colcon-systemd@ec02ba428d411fea8c9a37a1c2990d04b4f6a70a -
Branch / Tag:
refs/tags/0.1Beta - Owner: https://github.com/CraigBuilds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec02ba428d411fea8c9a37a1c2990d04b4f6a70a -
Trigger Event:
release
-
Statement type:
File details
Details for the file colcon_systemd-0.1.0-py3-none-any.whl.
File metadata
- Download URL: colcon_systemd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14578447e66f202a1c9cf6673bafe5f7d40d21c921add53eb0cbe081bb5a9db
|
|
| MD5 |
ce80bae2f52cc560967ee6d30d2443a3
|
|
| BLAKE2b-256 |
9040c67415a82545ae4d1750e2f67fcf1a15271867ec30b017d92d9ec4d2e619
|
Provenance
The following attestation bundles were made for colcon_systemd-0.1.0-py3-none-any.whl:
Publisher:
release.yml on CraigBuilds/colcon-systemd
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
colcon_systemd-0.1.0-py3-none-any.whl -
Subject digest:
b14578447e66f202a1c9cf6673bafe5f7d40d21c921add53eb0cbe081bb5a9db - Sigstore transparency entry: 1181325730
- Sigstore integration time:
-
Permalink:
CraigBuilds/colcon-systemd@ec02ba428d411fea8c9a37a1c2990d04b4f6a70a -
Branch / Tag:
refs/tags/0.1Beta - Owner: https://github.com/CraigBuilds
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ec02ba428d411fea8c9a37a1c2990d04b4f6a70a -
Trigger Event:
release
-
Statement type: