From 9537943fa519a9ddb201e83b92c7195b85bfa989 Mon Sep 17 00:00:00 2001 From: maximstewart Date: Fri, 5 Feb 2021 00:29:23 -0600 Subject: [PATCH] Added to requirements and fixed logging --- linux-requirements.txt | 1 + src/core/__init__.py | 3 ++- src/core/utils/Logger.py | 7 +++++-- src/linux-start.sh | 12 +++++------- src/socket_run.sh | 13 +++++++++++-- windows-requirements.txt | 3 ++- 6 files changed, 26 insertions(+), 13 deletions(-) mode change 100644 => 100755 src/linux-start.sh diff --git a/linux-requirements.txt b/linux-requirements.txt index 50c5c8b..ab1669a 100644 --- a/linux-requirements.txt +++ b/linux-requirements.txt @@ -1,3 +1,4 @@ +eventlet==0.30.1 Flask==1.1.1 flask-oidc==1.4.0 Flask-Login==0.5.0 diff --git a/src/core/__init__.py b/src/core/__init__.py index 6d9e1f5..da5b723 100644 --- a/src/core/__init__.py +++ b/src/core/__init__.py @@ -13,7 +13,7 @@ from flask_login import current_user, login_user, logout_user, LoginManager # Apoplication imports - +from core.utils import Logger # Configs and 'init' @@ -47,6 +47,7 @@ app.config.update({ oidc = OpenIDConnect(app) login_manager = LoginManager(app) bcrypt = Bcrypt(app) +logger = Logger().get_logger() def oidc_loggedin(): diff --git a/src/core/utils/Logger.py b/src/core/utils/Logger.py index a09cd5f..a1b7722 100644 --- a/src/core/utils/Logger.py +++ b/src/core/utils/Logger.py @@ -6,9 +6,12 @@ import os, logging class Logger: def __init__(self): - pass + self.logger = self.create_logger("flask_app") - def get_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True): + def get_logger(self): + return self.logger + + def create_logger(self, loggerName = "NO_LOGGER_NAME_PASSED", createFile = True): """ Create a new logging object and return it. :note: diff --git a/src/linux-start.sh b/src/linux-start.sh old mode 100644 new mode 100755 index 0c1aac0..ecfaa79 --- a/src/linux-start.sh +++ b/src/linux-start.sh @@ -7,7 +7,6 @@ function main() { SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )" - cd "${SCRIPTPATH}" echo "Working Dir: " $(pwd) source "../venv/bin/activate" @@ -20,11 +19,10 @@ function main() { # Note can replace 127.0.0.1 with 0.0.0.0 to make it 'network/internet' accessable... # Note: NEED -k eventlet for this to work! I spent too many hours on this... # : IE : - gunicorn wsgi:app -p app.pid \ - -b $ADDR:$PORT \ - -k eventlet \ - -w $WORKER_COUNT \ - --timeout $TIMEOUT \ - --log-level $LOG_LEVEL + gunicorn wsgi:app -p app.pid -b $ADDR:$PORT \ + -k eventlet \ + -w $WORKER_COUNT \ + --timeout $TIMEOUT \ + --log-level $LOG_LEVEL } main $@; diff --git a/src/socket_run.sh b/src/socket_run.sh index b17b82b..110ec79 100755 --- a/src/socket_run.sh +++ b/src/socket_run.sh @@ -7,9 +7,18 @@ function main() { SCRIPTPATH="$( cd "$(dirname "")" >/dev/null 2>&1 ; pwd -P )" - cd "${SCRIPTPATH}" echo "Working Dir: " $(pwd) source "../venv/bin/activate" - gunicorn --bind unix:/tmp/app.sock wsgi:app -p app.pid + + LOG_LEVEL=debug + WORKER_COUNT=1 + TIMEOUT=120 + + # : IE : + gunicorn wsgi:app -p app.pid -b unix:/tmp/app.sock \ + -k eventlet \ + -w $WORKER_COUNT \ + --timeout $TIMEOUT \ + --log-level $LOG_LEVEL } main $@; diff --git a/windows-requirements.txt b/windows-requirements.txt index 165ff8f..45a1e8a 100644 --- a/windows-requirements.txt +++ b/windows-requirements.txt @@ -1,3 +1,4 @@ +eventlet==0.30.1 Flask==1.1.1 flask-oidc==1.4.0 Flask-Login==0.5.0 @@ -7,4 +8,4 @@ Flask-WTF==0.14.3 waitress==1.4.3 SQLAlchemy==1.3.11 Werkzeug==0.16.0 -WTForms==2.2.1 \ No newline at end of file +WTForms==2.2.1