Making services start when the Raspberry Pi starts
When we ran the drive path example in the last chapter, we needed two SSH terminals, one to start the Inventor HAT service and another to start the drive behavior. This is pretty inconvenient.We want to turn on the robot, let it tell us that it’s ready, and then point your phone app at it to control it. So how do we launch services automatically? This is a building block we can use for other services.
The tool systemd is used by Raspberry Pi OS to automatically launch programs. systemd lets you control programs’ lifecycle and inspect their state. It can control when they run, how they run, as which user, which directory they start in (you’ve been using the
/home/<username>directory), and capture their logs as journals. We’ve used systemd before, in Chapter 6, to start Mosquitto.
We are going to do two things to make this useful, as follows:
- Use systemd to automatically start the Inventor HAT service...