spiri-services/service/roscore.service

16 lines
743 B
SYSTEMD
Raw Normal View History

2021-04-06 15:21:30 -03:00
[Unit]
After=NetworkManager.service time-sync.target
[Service]
Type=forking
User=spiri
# Start roscore as a fork and then wait for the tcp port to be opened
# —————————————————————-
# Source all the environment variables, start roscore in a fork
# Since the service type is forking, systemd doesnt mark it as
# started until the original process exits, so we have the
# non-forked shell wait until it can connect to the tcp opened by
# roscore, and then exit, preventing conflicts with dependant services
ExecStart=/bin/sh -c ". /opt/ros/melodic/setup.sh; . /etc/ros/env.sh; roscore & while ! echo exit | nc localhost 11311 > /dev/null; do sleep 1; done"
[Install]
WantedBy=multi-user.target