working service

This commit is contained in:
aj 2020-07-20 22:24:59 +01:00
parent 786b530dc1
commit 2fec436cbe
3 changed files with 5 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
scratch.py scratch.py
service.json service.json
ticker-env
*~* *~*
*# *#

View File

@ -7,6 +7,8 @@ ExecStart=/usr/bin/python3 /home/pi/ticker/main.py
[Service] [Service]
Environment=PYTHONUNBUFFERED=1 Environment=PYTHONUNBUFFERED=1
User=pi
EnvironmentFile=/home/pi/ticker/ticker-env
Type=simple Type=simple
[Install] [Install]

View File

@ -1,11 +1,12 @@
import logging import logging
import os
from ticker.ticker import Ticker from ticker.ticker import Ticker
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
fmlogger = logging.getLogger('fmframework') fmlogger = logging.getLogger('fmframework')
logger.setLevel('DEBUG') logger.setLevel('DEBUG')
file_handler = logging.FileHandler("ticker.log") file_handler = logging.FileHandler(f"{os.environ.get('TICKER_LOG_DIR', '')}ticker.log")
file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(name)s - %(funcName)s - %(message)s')) file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(name)s - %(funcName)s - %(message)s'))
logger.addHandler(file_handler) logger.addHandler(file_handler)
fmlogger.addHandler(file_handler) fmlogger.addHandler(file_handler)