xqms / rosmon

ROS node launcher & monitoring daemon
Other
180 stars 47 forks source link

using mon with systemd type service #181

Open tugbakara opened 10 months ago

tugbakara commented 10 months ago

Hi, I want to use mon with system servise as:

[Unit]
Description=Robot Bringup Launch Service
After=network.target

[Service]
Type=simple
ExecStart=/bin/bash -c "source /path/to/my/ws/devel/setup.bash && mon launch abcd.launch"
ExecStop=/usr/bin/pkill -f "mon launch diffbot_base abcd.launch"
Restart=always

[Install]
WantedBy=multi-user.target

but I couldn't run this, and there is not any error, how can I make it run, or does mon support service?

tugbakara commented 10 months ago
sudo systemctl --all | grep mon_deneme
● mon_deneme.service   loaded    failed     failed    Robot Bringup Launch Service                                                    
xqms commented 10 months ago

Here's a typical systemd unit file we have been using:

[Unit]
Description=My ROS service
After=network-online.target
Wants=network-online.target
Requires=roscore.service
AssertPathExists=/opt/ros

[Service]
Type=simple
User=my_username
TasksMax=infinity
KillSignal=SIGINT
ExecStart=/bin/bash -c ' \
  source /home/my_workspace/install/setup.bash && \
  rosrun rosmon_core rosmon --name rosmon_context --disable-ui --flush-stdout --log /tmp/context.log PKG launchfile.launch \
'

[Install]
WantedBy=default.target

and we start the roscore using another unit file (roscore.service):

[Unit]
Description=ROS Master
After=network-online.target
After=smbd.target
Wants=network-online.target
Wants=smbd.target
AssertPathExists=/opt/ros

[Service]
Type=simple
User=my_username
SyslogIdentifier=roscore
TasksMax=infinity
KillSignal=SIGINT
ExecStart=/bin/bash -c ' \
  source $${ROS_SETUP:=/opt/ros/noetic/setup.bash} && \
  exec /opt/ros/noetic/bin/roscore -w 20 -t 8 \
'

[Install]
WantedBy=default.target

(the smbd.target is probably not required in your case)