Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging endpoint #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add logging endpoint #41

wants to merge 5 commits into from

Conversation

chrstnbwnkl
Copy link
Collaborator

Adds a new end point to the REST API (/api/v1/logs/{log_type}, available log types are app, worker and builder). Unfortunately, supervisor can not be configured with a custom logger, which would enable us to have consistent behavior across the stack.

@@ -13,8 +13,6 @@ ADMIN_PASS=admin
# DATA_DIR=/home/nilsnolde/dev/gis-ops/routing-graph-packager/data
VALHALLA_URL="http://app"

VALHALLA_IMAGE=gisops/valhalla:latest
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superfluous

@@ -1,12 +1,7 @@
repos:
- repo: https://github.com/ambv/black
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just use ruff for linting and formatting

FROM ghcr.io/valhalla/valhalla:latest as builder
LABEL [email protected]
FROM ghcr.io/valhalla/valhalla:latest AS builder
LABEL maintainer="Nils Nolde <[email protected]>"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old format was deprecated

python-is-python3 \
python3-pip \
python3-venv \
curl > /dev/null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also contains the ubuntu 24.04 lts update


ENV POETRY_BIN /root/.local/bin/poetry
ENV POETRY_BIN=/root/.local/bin/poetry
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

old format was deprecated

@@ -15,17 +15,14 @@
from routing_packager_app import SETTINGS
from routing_packager_app.db import get_db
from routing_packager_app.api_v1.models import Job, User
from routing_packager_app.logger import AppSmtpHandler, get_smtp_details
from routing_packager_app.logger import AppSmtpHandler, get_smtp_details, LOGGER
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consistent use of the logger throughout the app

@@ -1,3 +1,6 @@
from routing_packager_app.logger import LOGGING_CONFIG
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice: gunicorn allows us to pass a custom logging config!

@@ -24,7 +24,7 @@ async def lifespan(app: FastAPI):
p.mkdir(exist_ok=True)
SETTINGS.get_output_path().mkdir(exist_ok=True)
yield
app.state.redis_pool.shutdown()
await app.state.redis_pool.shutdown()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was causing a warning


from fastapi.security import HTTPBasicCredentials
from geoalchemy2 import Geography
from pydantic import EmailStr
from sqlalchemy import Column
from sqlalchemy_utils import PasswordType
from sqlmodel import SQLModel, Field, DateTime, Relationship, Session, select, AutoString
from sqlmodel import AutoString, DateTime, Field, Relationship, Session, SQLModel, select
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ruff also does isort's job now

@@ -79,6 +79,19 @@ def get_tmp_data_dir(self) -> Path:

return tmp_data_dir

def get_logging_dir(self) -> Path:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally all logs are written into the tmp_data_dir logs subdirectory, so they are easily shared with the FastAPI app.

@@ -31,7 +35,7 @@ wait_for_lock() {
count=$(( $count + $sleep ))
done

echo "ERROR: max count reached"
log_message "ERROR: max count reached"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attach origin and date time to message for better logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant