Health, Readiness, and Lifespan

Alive is not ready

A liveness endpoint says the Python process is alive and can answer a cheap request. A readiness endpoint checks whether it can do real work: Ollama is reachable and the configured model exists. Load expensive shared resources once during the application's startup-to-shutdown lifespan, instead of repeating setup for every request.

Uvicorn is the web server that runs a FastAPI application. Use one Uvicorn worker process on this small CPU host. More workers would copy Python state and fight over the same model service.

Warning: Do not make liveness perform generation. A slow model would cause restart loops precisely when the host is busy.