add gunicorn logging, GUNICORN to config.py

This commit is contained in:
Lili (Tlapka) 2022-11-24 16:56:23 +01:00
parent 444601dab8
commit 22b4ee68d9
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import os import os
import logging
from flask import Flask from flask import Flask
from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.schedulers.background import BackgroundScheduler
from tlapbot.db import get_db from tlapbot.db import get_db
@ -7,7 +8,7 @@ from tlapbot.owncast_helpers import is_stream_live, give_points_to_chat
def create_app(test_config=None): def create_app(test_config=None):
app = Flask(__name__, instance_relative_config=True) app = Flask(__name__, instance_relative_config=True)
# ensure the instance folder exists # ensure the instance folder exists
try: try:
os.makedirs(app.instance_path) os.makedirs(app.instance_path)
@ -24,6 +25,12 @@ def create_app(test_config=None):
app.config.from_pyfile('config.py', silent=True) app.config.from_pyfile('config.py', silent=True)
app.config.from_pyfile('redeems.py', silent=True) app.config.from_pyfile('redeems.py', silent=True)
# Make logging work for gunicorn-ran instances of tlapbot.
if app.config['GUNICORN'] is True:
gunicorn_logger = logging.getLogger('gunicorn.error')
app.logger.handlers = gunicorn_logger.handlers
app.logger.setLevel(gunicorn_logger.level)
# prepare webhooks and redeem dashboard blueprints # prepare webhooks and redeem dashboard blueprints
from . import owncast_webhooks from . import owncast_webhooks
from . import owncast_redeem_dashboard from . import owncast_redeem_dashboard

View File

@ -3,4 +3,5 @@ OWNCAST_ACCESS_TOKEN=''
OWNCAST_INSTANCE_URL='http://localhost:8080' OWNCAST_INSTANCE_URL='http://localhost:8080'
POINTS_CYCLE_TIME=600 POINTS_CYCLE_TIME=600
POINTS_AMOUNT_GIVEN=10 POINTS_AMOUNT_GIVEN=10
LIST_REDEEMS=False LIST_REDEEMS=False
GUNICORN=False