diff --git a/.github/workflows/gatekeeper-build.yml b/.github/workflows/gatekeeper-build.yml index cb5c92c..e437969 100644 --- a/.github/workflows/gatekeeper-build.yml +++ b/.github/workflows/gatekeeper-build.yml @@ -15,17 +15,17 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.11 + - name: Set up Python 3.12 uses: actions/setup-python@v4 with: - python-version: '3.11' + python-version: '3.12' - name: Add conda to system path run: | # $CONDA is an environment variable pointing to the root of the miniconda directory echo $CONDA/bin >> $GITHUB_PATH - name: Install dependencies run: | - conda install -y python=3.11 + conda install -y python=3.12 conda env update --file environment-min.yml --name base - name: Lint with flake8 run: | diff --git a/deployment/gatekeeper.logrotate b/deployment/gatekeeper.logrotate index e1724e2..f1f34ce 100644 --- a/deployment/gatekeeper.logrotate +++ b/deployment/gatekeeper.logrotate @@ -1,19 +1,7 @@ -/home/pasta/Gatekeeper/*.log { - monthly - missingok - rotate 6 - compress - delaycompress - notifempty - sharedscripts - postrotate - systemctl reload gatekeeper.service - endscript -} -/home/pasta/Gatekeeper/webapp/gatekeeper.log { +/var/log/pasta/*.log { daily missingok - rotate 24 + rotate 28 compress delaycompress notifempty diff --git a/deployment/gatekeeper.service b/deployment/gatekeeper.service index 19dc59e..f40ca2d 100644 --- a/deployment/gatekeeper.service +++ b/deployment/gatekeeper.service @@ -3,6 +3,11 @@ Description=gunicorn uvicorn service for PASTA Gatekeeper After=syslog.target [Service] +User=pasta +Group=www-data +WorkingDirectory=/home/pasta/Gatekeeper/webapp +Environment="PATH=/home/pasta/miniconda3/envs/gatekeeper/bin" + ExecStart=/home/pasta/miniconda3/envs/gatekeeper/bin/gunicorn \ -b \ -w 8 \ @@ -13,8 +18,8 @@ ExecStart=/home/pasta/miniconda3/envs/gatekeeper/bin/gunicorn \ --max-requests 100 \ --max-requests-jitter 10 \ --log-level info \ ---access-logfile /home/pasta/Gatekeeper/gunicorn.log \ ---error-logfile /home/pasta/Gatekeeper/gunicorn-error.log \ +--access-logfile /var/log/pasta/gunicorn.log \ +--error-logfile /var/log/gunicorn-error.log \ --user pasta ExecReload=/bin/kill -s HUP $MAINPID @@ -23,7 +28,7 @@ TimeoutStopSec=5 PrivateTmp=true # Requires systemd version 211 or newer -RuntimeDirectory=/home/pasta/Gatekeeper/webapp +RuntimeDirectory=gatekeeper Restart=always Type=notify NotifyAccess=all diff --git a/environment-min.yml b/environment-min.yml index 75f22d0..02e0e28 100644 --- a/environment-min.yml +++ b/environment-min.yml @@ -5,7 +5,7 @@ channels: dependencies: - daiquiri - uvicorn - - python=3.11 + - python=3.12 - pytest - httpx - black diff --git a/environment.yml b/environment.yml index b325fb5..e225b53 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: gatekeeper +name: gatekeeper-dev channels: - conda-forge - defaults @@ -7,7 +7,7 @@ dependencies: - _openmp_mutex=4.5 - annotated-types=0.7.0 - anyio=4.4.0 - - black=24.4.2 + - black=24.8.0 - bzip2=1.0.8 - ca-certificates=2024.7.4 - certifi=2024.7.4 @@ -18,10 +18,10 @@ dependencies: - email-validator=2.2.0 - email_validator=2.2.0 - exceptiongroup=1.2.2 - - fastapi=0.112.0 + - fastapi=0.112.1 - fastapi-cli=0.0.5 - gmp=6.3.0 - - gunicorn=22.0.0 + - gunicorn=23.0.0 - h11=0.14.0 - h2=4.1.0 - hpack=4.0.0 @@ -59,28 +59,28 @@ dependencies: - pydantic-core=2.20.1 - pygments=2.18.0 - pytest=8.3.2 - - python=3.11.9 + - python=3.12.5 - python-dateutil=2.9.0 - python-json-logger=2.0.7 - python-multipart=0.0.9 - - python_abi=3.11 + - python_abi=3.12 - readline=8.2 - rich=13.7.1 - - setuptools=72.1.0 + - setuptools=72.2.0 - shellingham=1.5.4 - six=1.16.0 - sniffio=1.3.1 - - starlette=0.37.2 - - time-machine=2.14.2 + - starlette=0.38.2 + - time-machine=2.15.0 - tk=8.6.13 - tomli=2.0.1 - - typer=0.12.3 - - typer-slim=0.12.3 - - typer-slim-standard=0.12.3 + - typer=0.12.4 + - typer-slim=0.12.4 + - typer-slim-standard=0.12.4 - typing-extensions=4.12.2 - typing_extensions=4.12.2 - tzdata=2024a - - uvicorn=0.30.4 - - wheel=0.43.0 + - uvicorn=0.30.6 + - wheel=0.44.0 - xz=5.2.6 -prefix: /home/pasta/miniconda3/envs/gatekeeper +prefix: /home/servilla/miniconda3/envs/gatekeeper-dev diff --git a/requirements.txt b/requirements.txt index d7a9698..cc3a0df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ annotated-types==0.7.0 anyio==4.4.0 -black==24.4.2 +black==24.8.0 certifi==2024.7.4 click==8.1.7 colorama==0.4.6 @@ -8,9 +8,9 @@ daiquiri==3.0.0 dnspython==2.6.1 email_validator==2.2.0 exceptiongroup==1.2.2 -fastapi==0.112.0 +fastapi==0.112.1 fastapi-cli==0.0.5 -gunicorn==22.0.0 +gunicorn==23.0.0 h11==0.14.0 h2==4.1.0 hpack==4.0.0 @@ -39,15 +39,15 @@ python-dateutil==2.9.0 python-json-logger==2.0.7 python-multipart==0.0.9 rich==13.7.1 -setuptools==72.1.0 +setuptools==72.2.0 shellingham==1.5.4 six==1.16.0 sniffio==1.3.1 -starlette==0.37.2 -time-machine==2.14.2 +starlette==0.38.2 +time-machine==2.15.0 tomli==2.0.1 -typer==0.12.3 -typer-slim==0.12.3 +typer==0.12.4 +typer-slim==0.12.4 typing_extensions==4.12.2 -uvicorn==0.30.4 -wheel==0.43.0 +uvicorn==0.30.6 +wheel==0.44.0 diff --git a/webapp/config.py.template b/webapp/config.py.template index d29d92b..2c453f4 100644 --- a/webapp/config.py.template +++ b/webapp/config.py.template @@ -13,10 +13,15 @@ 3/28/23 """ import logging +import pathlib class Config: + # Logging + LOG_PATH = pathlib.Path("") + LOG_LEVEL = logging.WARN + # PASTA+ authentication token attributes PUBLIC = "public" SYSTEM = "https://pasta.edirepository.org/authentication" @@ -41,8 +46,5 @@ class Config: # Static directory path STATIC = "/static" - # Logging level - LEVEL = logging.INFO - # Proxy timeout (seconds) TIMEOUT = 120.0 diff --git a/webapp/main.py b/webapp/main.py index 77fccf7..44815cf 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -25,10 +25,15 @@ from filter import audit from views import index -cwd = os.path.dirname(os.path.realpath(__file__)) -logfile = cwd + "/gatekeeper.log" -daiquiri.setup(level=Config.LEVEL, - outputs=(daiquiri.output.File(logfile), "stdout",)) + +daiquiri.setup( + level=Config.LOG_LEVEL, + outputs=( + daiquiri.output.File(Config.LOG_PATH / "gatekeeper.log"), + 'stdout', + ), +) + logger = daiquiri.getLogger(__name__)