Added system service
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,6 +2,7 @@
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
.mypy_cache/
|
||||
*.log
|
||||
|
||||
# local files
|
||||
.env
|
||||
|
||||
3
app.py
3
app.py
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import time
|
||||
import sys
|
||||
import threading
|
||||
from dsmr_parser import telegram_specifications
|
||||
from dsmr_parser.clients import SerialReader, SERIAL_SETTINGS_V2_2, SERIAL_SETTINGS_V4, SERIAL_SETTINGS_V5
|
||||
@@ -16,7 +17,7 @@ def main():
|
||||
logfmt = "%(asctime)s [%(levelname)-5.5s] [%(name)s] %(message)s"
|
||||
logging.basicConfig(level=logging.INFO, format=logfmt, filename="dsmr2mqtt.log")
|
||||
# set up logging to console
|
||||
consolelog = logging.StreamHandler()
|
||||
consolelog = logging.StreamHandler(sys.stdout)
|
||||
consolelog.setLevel(logging.INFO)
|
||||
# set a format which is simpler for console use
|
||||
formatter = logging.Formatter(logfmt)
|
||||
|
||||
14
dsmr2mqtt.service
Normal file
14
dsmr2mqtt.service
Normal file
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=DSMR 2 MQTT Service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/python3 -u app.py
|
||||
WorkingDirectory=/home/pi/dsmr2mqtt
|
||||
StandardOutput=inherit
|
||||
StandardError=inherit
|
||||
Restart=always
|
||||
User=pi
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user