robmarkcole / rpi-enviro-mqtt

Send air quality data from a Pimoroni RPi Enviro+ over MQTT
https://learn.pimoroni.com/tutorial/sandyj/getting-started-with-enviro-plus
Apache License 2.0
45 stars 12 forks source link

Add service info #14

Closed robmarkcole closed 4 years ago

robmarkcole commented 4 years ago

Something like

--- Run
sudo nano /etc/systemd/system/envmqtt.service

--- Edit file
[Unit]
Description=Enviro+ MQTT Logger
After=network.target

[Service]
ExecStart=/usr/bin/python3 /usr/src/enviroplus/examples/mqtt-all.py --broker <IP-address>
WorkingDirectory=/usr/src/enviroplus/examples
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target

--- Run
sudo systemctl enable envmqtt.service
sudo systemctl start envmqtt.service
robmarkcole commented 4 years ago

done