Skip to content

Commit

Permalink
Merge pull request #298 from KNMI/access-log
Browse files Browse the repository at this point in the history
Fix access log.
  • Loading branch information
maartenplieger authored Oct 6, 2023
2 parents be90cc7 + 85cb0fd commit 32cc61e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ then
fi

echo "Start serving on ${EXTERNALADDRESS}"
gunicorn --bind 0.0.0.0:8080 --workers=4 -k uvicorn.workers.UvicornWorker --disable-redirect-access-to-syslog --access-logfile - --access-logformat 'accesslog %(h)s ; %(t)s ; %(H)s ; %(m)s ; %(u)s ; %(q)s ; %(s)s ; %(M)s ; "%(a)s"' main:app
gunicorn --bind 0.0.0.0:8080 --workers=4 -k uvicorn.workers.UvicornWorker --disable-redirect-access-to-syslog --access-logfile - main:app


4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ USER root
LABEL maintainer="[email protected]"

# Version should be same as in Definitions.h
LABEL version="2.13.5"

######### First stage (build) ############
LABEL version="2.13.6"

# Try to update image packages
RUN apt-get -q -y update \
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
**Version 2.13.6 2023-10-06**
- Restored access log to original format (was broken since move to FastAPI)

**Version 2.13.5 2023-10-05**
- KNMI HDF5 dual-pol data now picks scans 15, 16, 6,
14, 5, 13, 4, 12, 3
Expand Down
2 changes: 1 addition & 1 deletion adagucserverEC/Definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef Definitions_H
#define Definitions_H

#define ADAGUCSERVER_VERSION "2.13.5" // Please also update in the Dockerfile to the same version
#define ADAGUCSERVER_VERSION "2.13.6" // Please also update in the Dockerfile to the same version

// CConfigReaderLayerType
#define CConfigReaderLayerTypeUnknown 0
Expand Down
6 changes: 6 additions & 0 deletions python/python_fastapi_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from brotli_asgi import BrotliMiddleware
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from asgi_logger import AccessLoggerMiddleware

from configure_logging import configure_logging
from routers.autowms import autowms_router
Expand All @@ -21,6 +22,11 @@

app = FastAPI()

# Set uvicorn access log format using middleware
access_log_format = 'accesslog %(h)s ; %(t)s ; %(H)s ; %(m)s ; %(U)s ; %(q)s ; %(s)s ; %(M)s ; "%(a)s"'
logging.getLogger("uvicorn.access").handlers.clear()
app.add_middleware(AccessLoggerMiddleware, format=access_log_format)
logging.getLogger("access").propagate = False

@app.middleware("http")
async def add_process_time_header(request: Request, call_next):
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Jinja2~=3.1
OWSLib~=0.29.2
Pillow~=10.0
Werkzeug~=2.3
asgi-logger~=0.1.0
brotli-asgi~=1.4
cachetools~=5.3
cftime~=1.6
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ anyio==4.0.0
# via
# httpcore
# starlette
asgi-logger==0.1.0
# via -r requirements.in
asgiref==3.7.2
# via asgi-logger
brotli==1.1.0
# via
# -r requirements.in
Expand Down Expand Up @@ -108,6 +112,7 @@ starlette==0.27.0
# fastapi
typing-extensions==4.8.0
# via
# asgiref
# fastapi
# pydantic
# uvicorn
Expand Down

0 comments on commit 32cc61e

Please sign in to comment.