Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,6 @@ with admin"). Runtime runbook: `docs/identity-management.md`.
- **New API endpoint**: Add a route to `main.py` or a new router under `routers/`.
- **Configuration**: Add fields to `ServerConfig` in `config.py`. Keep defaults conservative.
- **Tests**: Every handler should have a unit test in `tests/handlers/`. Integration tests live in `tests/integration/`.
- **Server process**: Gunicorn runs one `uvicorn_worker.UvicornWorker` (`worker_class` in `main.py` `run()`), from the `uvicorn-worker` package. Do not use the deprecated `uvicorn.workers` module.

Run `uv run pytest tests/ -q` to verify before committing.
2 changes: 1 addition & 1 deletion context_intelligence_server/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
_MAX_BYTES = 10 * 1024 * 1024
_BACKUP_COUNT = 5

# Third-party loggers (gunicorn + uvicorn.workers.UvicornWorker) that install
# Third-party loggers (gunicorn + uvicorn_worker.UvicornWorker) that install
# their OWN handlers and do NOT propagate by default. Left alone, their lines
# (startup, access, errors) reach stdout as PLAIN TEXT, which Azure Log Analytics
# cannot parse. We strip those handlers and force propagation so every record
Expand Down
2 changes: 1 addition & 1 deletion context_intelligence_server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def load_config(self) -> None:
for key, value in {
"bind": f"{_settings.server_host}:{_settings.server_port}",
"workers": workers,
"worker_class": "uvicorn.workers.UvicornWorker",
"worker_class": "uvicorn_worker.UvicornWorker",
"timeout": _settings.gunicorn_worker_timeout,
"graceful_timeout": _settings.gunicorn_graceful_timeout,
"loglevel": _settings.log_level.lower(),
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ requires-python = ">=3.11"
dependencies = [
"fastapi>=0.115.0",
"uvicorn[standard]>=0.30.0",
"uvicorn-worker>=0.4.0",
"gunicorn>=23.0.0",
"pydantic-settings>=2.14.2",
"neo4j>=5.0",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def test_configured_stdout_handler_emits_one_line_json(self) -> None:
def test_uvicorn_gunicorn_loggers_route_through_json_formatter(self) -> None:
"""uvicorn/gunicorn loggers must emit through the root JsonFormatter as one-line JSON.

Production runs gunicorn + uvicorn.workers.UvicornWorker. Those frameworks
Production runs gunicorn + uvicorn_worker.UvicornWorker. Those frameworks
install their OWN handlers on the ``uvicorn*`` / ``gunicorn*`` loggers with
``propagate=False`` so their lines (startup, access, errors) reach stdout as
PLAIN TEXT, which Azure Log Analytics cannot parse as JSON.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from context_intelligence_server.config import get_settings
from context_intelligence_server.main import run
from gunicorn.app.base import BaseApplication
from uvicorn.workers import UvicornWorker
from uvicorn_worker import UvicornWorker


def test_run_uses_gunicorn_with_settings() -> None:
Expand Down
15 changes: 15 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading