From acd6978406344696be56be143da720382d8c41ad Mon Sep 17 00:00:00 2001 From: CongLiu Date: Thu, 4 Nov 2021 15:54:40 +0800 Subject: [PATCH 1/2] add roslaunch_ns --- src/robot_upstart/job.py | 3 +++ templates/job-start.em | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/robot_upstart/job.py b/src/robot_upstart/job.py index 54fea50..a5dbb21 100644 --- a/src/robot_upstart/job.py +++ b/src/robot_upstart/job.py @@ -100,6 +100,9 @@ def __init__(self, name="ros", interface=None, user=None, workspace_setup=None, # This will be desired if the nodes spawned by this job are intended to # connect to an existing master. self.roslaunch_wait = False + + # Set the roslaunch namespace + self.roslaunch_ns = "" # Set the string of the "After=" section # of the generated Systemd service file diff --git a/templates/job-start.em b/templates/job-start.em index d69fd03..697894b 100644 --- a/templates/job-start.em +++ b/templates/job-start.em @@ -104,7 +104,7 @@ if [ "$?" != "0" ]; then fi # Punch it. -setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME @(roslaunch_wait?'--wait ')& +setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME __ns:=@(roslaunch_ns) @(roslaunch_wait?'--wait ')& PID=$! log info "@(name): Started roslaunch as background process, PID $PID, ROS_LOG_DIR=$ROS_LOG_DIR" From d935600959fe5c4f08d0b1ff9f887da5985fea76 Mon Sep 17 00:00:00 2001 From: CongLiu Date: Wed, 15 Dec 2021 21:25:48 +0800 Subject: [PATCH 2/2] templates/job-start.em: add roslaunch_log_opt --- templates/job-start.em | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/templates/job-start.em b/templates/job-start.em index 697894b..691913d 100644 --- a/templates/job-start.em +++ b/templates/job-start.em @@ -28,6 +28,23 @@ #!/bin/bash # THIS IS A GENERATED FILE, NOT RECOMMENDED TO EDIT. +roslaunch_log_opt="--log" + +while getopts ":s" opt; do + case $opt in + s) + roslaunch_log_opt="--screen" + ;; + :) + echo "Option -$OPTARG requires an argument." + exit 1 + ;; + ?) + echo "Invalid option: -$OPTARG index:$OPTIND" + ;; + esac +done + function log() { logger -s -p user.$1 ${@@:2} } @@ -104,7 +121,7 @@ if [ "$?" != "0" ]; then fi # Punch it. -setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME __ns:=@(roslaunch_ns) @(roslaunch_wait?'--wait ')& +setpriv --reuid @(user) --regid @(user) --init-groups roslaunch $LAUNCH_FILENAME __ns:=@(roslaunch_ns) @(roslaunch_wait?'--wait ') $roslaunch_log_opt& PID=$! log info "@(name): Started roslaunch as background process, PID $PID, ROS_LOG_DIR=$ROS_LOG_DIR"