17 lines
994 B
Markdown
17 lines
994 B
Markdown
# Creating systemd unit for Auto Start/Restart
|
|
### The steps below outline the process for creating a systemd service unit.
|
|
### This service will automatically start the python script.
|
|
|
|
## Procedure
|
|
|
|
1. Create the service template by copying `dht-start-restart@.service` into `/etc/systemd/system/`.
|
|
2. Define environment variables for an instance of this template by copying `dht-start-restart@pimonitoring1` into `/etc/default/`.
|
|
- __NOTE__: The instance should replace the name of the RPiZW. (e.g. pimonitoring2, etc.)
|
|
3. Create the instance and enable it with `sudo systemctl enable --now dht-start-restart@pimonitoring1`
|
|
- __NOTE__: It may be required to reload the systemd daemon. `sudo systemctl reload-daemon`
|
|
|
|
## Common Issues
|
|
- [ ] Is the `User=` in `dht-start-restart@.service` correct? pi vs. shaun
|
|
- [ ] Is the `{PATH_TO_FILE}` in `dht-start-restart@pimonitoring1` correct? `/home/pi` vs. `/home/shaun`
|
|
- [ ] Does the python script `main.py` contain any relative paths?
|