-
Notifications
You must be signed in to change notification settings - Fork 21
Add s6-overlay and Talos system manager support for physical_ai_server #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
92b620a
add s6 agent for system manager
GyuH13 af1de2f
chore: update Dockerfiles to install setuptools with no-cache and adj…
GyuH13 a735b7e
change location of socket volume mapping
GyuH13 cca8ee9
refactor: update Dockerfiles to copy system_manager directly and inst…
GyuH13 59d4a36
fix: update physical_ai_server image to use system-manager-dev for de…
GyuH13 5929d99
chore: add common service directory and update PYTHONPATH in ros2_ser…
GyuH13 833dbe6
chore: add physical_ai_server-pipeline to s6 user bundle in Dockerfiles
GyuH13 43461d0
remove system manager
GyuH13 ae15064
refactor: replace system_manager with robotis_system_manager in Docke…
GyuH13 43aa49a
rm system manager folder
GyuH13 eb58ac6
Merge branch 'main' of https://github.com/ROBOTIS-GIT/physical_ai_too…
GyuH13 d43b3f1
Update Dockerfile.arm64 to clone robotis_system_manager repository an…
GyuH13 9d66e30
change name to talos
GyuH13 fe80d65
Refactor Docker setup by removing unused s6 services and updating s6-…
GyuH13 aa9d982
Update Docker Compose configuration to use the latest image for the p…
GyuH13 f4bf99a
bump
GyuH13 86402d9
Add RMW_IMPLEMENTATION logging to ros2_service_run.sh for improved se…
GyuH13 aabfb8a
change shell
GyuH13 b918ec9
change check process function
GyuH13 09e9942
delete comments
GyuH13 178b45b
remove set -e in finish script
GyuH13 79d9c96
remove log-prepare folder
GyuH13 0acd2d6
docker arm64
GyuH13 1567dcb
remove gpg key error avoidance line
GyuH13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/usr/bin/with-contenv sh | ||
| # Agent service finish script | ||
| # Cleanup when service stops | ||
|
|
||
| # Remove socket file if it exists | ||
| [ -S /var/run/agent/s6_agent.sock ] && rm -f /var/run/agent/s6_agent.sock | ||
|
|
||
| exit 0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/command/with-contenv sh | ||
| # Agent service run script | ||
| # This script starts the s6-agent FastAPI service | ||
|
|
||
| set -e | ||
|
|
||
| # Ensure socket directory exists | ||
| mkdir -p /var/run/agent | ||
| chmod 777 /var/run/agent | ||
GyuH13 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Start uvicorn with Unix Domain Socket | ||
| # The agent is part of talos package | ||
| exec uvicorn talos.agent.s6_agent:app --uds /var/run/agent/s6_agent.sock --log-level info | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| longrun | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/command/with-contenv sh | ||
| # Reusable ROS2 service finish script template | ||
| # This script runs when the service is stopped. | ||
| # Usage: SERVICE_NAME=<name> /path/to/ros2_service_finish.sh [exit_code] | ||
|
|
||
| set -e | ||
|
|
||
| # Service name must be provided via environment variable | ||
| SERVICE_NAME="${SERVICE_NAME}" | ||
| if [ -z "${SERVICE_NAME}" ]; then | ||
| echo "Error: SERVICE_NAME environment variable must be set" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Log the finish event for debugging | ||
| EXIT_CODE=${1:-unknown} | ||
| echo "[${SERVICE_NAME} finish] Service stopped with exit code $EXIT_CODE" | ||
|
|
||
| # If we recorded a process group ID, send a final graceful SIGTERM to that group | ||
| # and wait until the processes are fully dead (or a timeout is reached). | ||
| PGID_FILE=/run/${SERVICE_NAME}.pgid | ||
| if [ -f "${PGID_FILE}" ]; then | ||
| PGID=$(cat "${PGID_FILE}" 2>/dev/null || echo "") | ||
| if [ -n "${PGID}" ]; then | ||
| echo "[${SERVICE_NAME} finish] Sending SIGTERM to process group ${PGID}" | ||
| # Negative PGID means "entire process group" to kill(2) | ||
| kill -TERM -"${PGID}" 2>/dev/null || echo "[${SERVICE_NAME} finish] Warning: kill -TERM -${PGID} failed or group already gone" | ||
|
|
||
| # Wait until the process group is gone, with a hard timeout | ||
| TIMEOUT=30 # total seconds to wait | ||
| SLEEP_INTERVAL=1 # seconds between checks | ||
| ELAPSED=0 | ||
|
|
||
| # Helper: returns 0 if PGID still has processes, 1 otherwise | ||
| pgid_alive() { | ||
| # 'ps -o pgid=' prints the PGID for each matching process; | ||
| # if there is at least one line, the group is still alive. | ||
| ps -o pgid= -g "${PGID}" 2>/dev/null | grep -q . | ||
| } | ||
ola31 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if pgid_alive; then | ||
| echo "[${SERVICE_NAME} finish] Waiting for process group ${PGID} to exit (timeout: ${TIMEOUT}s)..." | ||
| fi | ||
|
|
||
| while pgid_alive && [ "${ELAPSED}" -lt "${TIMEOUT}" ]; do | ||
| sleep "${SLEEP_INTERVAL}" | ||
| ELAPSED=$((ELAPSED + SLEEP_INTERVAL)) | ||
| done | ||
|
|
||
| if pgid_alive; then | ||
| echo "[${SERVICE_NAME} finish] Timeout waiting for process group ${PGID} to exit; sending SIGKILL" | ||
| kill -KILL -"${PGID}" 2>/dev/null || echo "[${SERVICE_NAME} finish] Warning: kill -KILL -${PGID} failed or group already gone" | ||
| else | ||
| echo "[${SERVICE_NAME} finish] Process group ${PGID} fully exited after ${ELAPSED}s" | ||
| fi | ||
| fi | ||
| fi | ||
|
|
||
| echo "[${SERVICE_NAME} finish] Finish script completed" | ||
|
|
||
| exit 0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/bin/bash | ||
| # Reusable ROS2 service run script template | ||
| # This script launches ROS2 commands for any service | ||
| # Usage: | ||
| # SERVICE_NAME=<name> ROS2_COMMAND="<full command>" /path/to/ros2_service_run.sh | ||
| # If ROS2_COMMAND is not set, defaults to: ros2 launch physical_ai_server ${SERVICE_NAME}.launch.py | ||
| # Note: This script is called via /command/with-contenv, so environment is already set up | ||
|
|
||
| set -e | ||
ola31 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Service name must be provided via environment variable | ||
| SERVICE_NAME="${SERVICE_NAME}" | ||
| if [ -z "${SERVICE_NAME}" ]; then | ||
| echo "Error: SERVICE_NAME environment variable must be set" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Set ROS_DOMAIN_ID if not already set (default to 30) | ||
| export ROS_DOMAIN_ID=${ROS_DOMAIN_ID:-30} | ||
| export ROS_DISTRO=${ROS_DISTRO:-jazzy} | ||
| export COLCON_WS=${COLCON_WS:-/root/ros2_ws} | ||
| export PATH=/opt/venv/bin:${PATH} | ||
| export PYTHONPATH=/opt/venv/lib/python3.12/site-packages:${PYTHONPATH} | ||
| export PYTHONPATH=${COLCON_WS}/src/physical_ai_tools/lerobot/src:${PYTHONPATH} | ||
|
|
||
| # Enable s6-overlay debug logging (set S6_VERBOSITY=1 for more verbose output) | ||
| export S6_VERBOSITY=${S6_VERBOSITY:-1} | ||
|
|
||
| echo "[${SERVICE_NAME}] Starting service..." | ||
| echo "[${SERVICE_NAME}] ROS_DOMAIN_ID=${ROS_DOMAIN_ID}" | ||
| echo "[${SERVICE_NAME}] ROS_DISTRO=${ROS_DISTRO}" | ||
| echo "[${SERVICE_NAME}] RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION}" | ||
| echo "[${SERVICE_NAME}] COLCON_WS=${COLCON_WS}" | ||
| echo "[${SERVICE_NAME}] PID: $$" | ||
|
|
||
| # Record process group ID so the finish script can target the whole group | ||
| PGID=$(ps -o pgid= -p $$ | tr -d ' ') | ||
| echo "[${SERVICE_NAME}] Process group: ${PGID}" | ||
| echo "${PGID}" > /run/${SERVICE_NAME}.pgid || true | ||
|
|
||
| # Source ROS2 environment | ||
| source /opt/ros/${ROS_DISTRO}/setup.bash | ||
| source ${COLCON_WS}/install/setup.bash | ||
|
|
||
| # Determine the command to execute | ||
| # If ROS2_COMMAND is set, use it; otherwise, use the default launch command | ||
| if [ -n "${ROS2_COMMAND}" ]; then | ||
| ROS2_CMD="${ROS2_COMMAND}" | ||
| echo "[${SERVICE_NAME}] Executing custom command: ${ROS2_CMD}" | ||
| else | ||
| ROS2_CMD="ros2 launch physical_ai_server ${SERVICE_NAME}.launch.py" | ||
| echo "[${SERVICE_NAME}] Executing default command: ${ROS2_CMD}" | ||
| fi | ||
|
|
||
| # Execute the ROS2 command | ||
| # Using 'exec' ensures the command becomes PID 1 of this service, | ||
| # which allows s6 to properly signal it and its children | ||
| # Note: stdout/stderr are automatically piped to ${SERVICE_NAME}-log via producer-for/consumer-for | ||
| exec bash -c "${ROS2_CMD}" | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| oneshot | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| if { mkdir -p /var/log/physical_ai_server } | ||
| if { chown nobody:nogroup /var/log/physical_ai_server } | ||
| chmod 02755 /var/log/physical_ai_server | ||
GyuH13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
GyuH13 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| physical_ai_server | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| physical_ai_server-pipeline | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/command/with-contenv sh | ||
| # Logging service for physical_ai_server | ||
| # Uses logutil-service which wraps s6-log with proper configuration | ||
|
|
||
| exec logutil-service /var/log/physical_ai_server | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| longrun | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/command/with-contenv sh | ||
| # Physical AI Server service finish script | ||
| # Uses reusable ROS2 service template | ||
|
|
||
| set -e | ||
|
|
||
| SERVICE_NAME="physical_ai_server" | ||
| COMMON_SCRIPT="/usr/local/lib/s6-services/ros2_service_finish.sh" | ||
|
|
||
| if [ -f "${COMMON_SCRIPT}" ]; then | ||
| # Use env to explicitly pass variables to the script | ||
| # The with-contenv wrapper will preserve these variables | ||
| exec /command/with-contenv env SERVICE_NAME="${SERVICE_NAME}" sh "${COMMON_SCRIPT}" "$@" | ||
| else | ||
| echo "Error: Common script not found at ${COMMON_SCRIPT}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| physical_ai_server-log | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/command/with-contenv bash | ||
| # Physical AI Server service run script | ||
| # Uses reusable ROS2 service template | ||
|
|
||
| set -e | ||
|
|
||
| SERVICE_NAME="physical_ai_server" | ||
| ROS2_COMMAND="ros2 launch physical_ai_server physical_ai_server_bringup.launch.py" | ||
| COMMON_SCRIPT="/usr/local/lib/s6-services/ros2_service_run.sh" | ||
|
|
||
| if [ -f "${COMMON_SCRIPT}" ]; then | ||
| export SERVICE_NAME="${SERVICE_NAME}" | ||
| export ROS2_COMMAND="${ROS2_COMMAND}" | ||
| # Use env to explicitly pass variables to the script | ||
| # The with-contenv wrapper will preserve these variables | ||
| exec /command/with-contenv env SERVICE_NAME="${SERVICE_NAME}" ROS2_COMMAND="${ROS2_COMMAND}" bash "${COMMON_SCRIPT}" | ||
| else | ||
| # Fallback if common script not available | ||
| echo "Error: Common script not found at ${COMMON_SCRIPT}" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| longrun | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.