To keep locally generated systemd service files separate from distribution files (as an example):
$ sudo mkdir -p /usr/local/lib/systemd/system $ sudo vim /usr/local/lib/systemd/system/bme680.service $ sudo systemctl enable bme680 $ sudo systemctl daemon-reload $ sudo systemctl start bme680
An example systemd service file in /etc/systemd/system might look like:
[Unit] Description=BME680 Collector Documentation=https://github.com/rburkholder/bme680 After=network.target [Service] Type=simple User=debian WorkingDirectory=/home/debian Environment="ID=02" "LOCATION=top floor" ExecStart=/home/debian/bme680/build/bme680-mqtt ${ID} ${LOCATION} ExecReload=kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=5s StandardOutput=null # note change with logrotate implemented, or to a memory file [Install] WantedBy=multi-user.target
The example from ecowitt2mqtt got me started - is a small CLI/web server that can receive data from Fine Offset weather stations (and their numerous white-labeled counterparts, like Ecowitt and Ambient Weather), adjust that data in numerous ways, and send it on to one or more MQTT brokers.
Reference to:
- systemd.service — Service unit configuration
- systemd.exec — Execution environment configuration - has list of expanded exit codes