systemctl

systemctl is a tool for starting and stopping tasks on linux. We are able to tell it to start our Docker container on boot.

follow this forum post to set up the autostart script

Then here are some useful commands for interacting with the service once it has started.

  # to see log of the robot service
journalctl -u robot.service -b

# to see live printouts of the robot service
journalctl -u robot.service -b -f

# see status of robot service
sudo systemctl status robot

# to restart robot service
sudo systemctl restart robot

# to stop robot service NOTE: must enable cmd below to enable boot 
sudo systemctl stop robot

# to enable boot robot service
sudo systemctl enable robot
# to disable boot robot service
sudo systemctl disable robot

# edit configs
sudo vim /lib/systemd/system/robot.service 

# apply configs
sudo systemctl daemon-reload
sudo systemctl start robot
  

Killing startup process

  sudo systemctl stop robot
sudo su root
  

And then as root:

  htop
  

Type /main (to find python3 main.py), then hit k, 9, Enter to kill the process. Press q to quit and Ctrl+D to log out of root.


Startup High level overview:

Boot → systemd → (bash script with docker settings) → Dockerfile → ros2 launch ...