The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix: remove separate health app
Yassin Kortam451ce161fcfb
diff --git a/Dockerfile b/Dockerfileindex 915daff999c..674378bdb8f 100644--- a/Dockerfile+++ b/Dockerfile@@ -68,7 +68,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtimeUSER root-RUN apk add --no-cache bash openssl tzdata nodejs npm python3 libsndfile supervisor && \+RUN apk add --no-cache bash openssl tzdata nodejs npm python3 libsndfile && \npm install -g [email protected] [email protected] [email protected] @isaacs/[email protected] [email protected] [email protected] [email protected] [email protected] && \GLOBAL="$(npm root -g)" && \for pkg in tar glob @isaacs/brace-expansion brace-expansion minimatch diff picomatch; do \@@ -95,7 +95,5 @@ RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \EXPOSE 4000/tcp-COPY docker/supervisord.conf /etc/supervisord.conf-ENTRYPOINT ["docker/prod_entrypoint.sh"]CMD ["--port", "4000"]diff --git a/deploy/charts/litellm-helm/templates/deployment.yaml b/deploy/charts/litellm-helm/templates/deployment.yamlindex a9b41e0d8e0..6aa1771b7bb 100644--- a/deploy/charts/litellm-helm/templates/deployment.yaml+++ b/deploy/charts/litellm-helm/templates/deployment.yaml@@ -129,12 +129,6 @@ spec:value: {{ $val | quote }}{{- end }}{{- end }}- {{- if .Values.separateHealthApp }}- - name: SEPARATE_HEALTH_APP- value: "1"- - name: SEPARATE_HEALTH_PORT- value: {{ .Values.separateHealthPort | default "8081" | quote }}- {{- end }}{{- with .Values.extraEnvVars }}{{- toYaml . | nindent 12 }}{{- end }}@@ -175,15 +169,10 @@ spec:- name: httpcontainerPort: {{ .Values.service.port }}protocol: TCP- {{- if .Values.separateHealthApp }}- - name: health- containerPort: {{ .Values.separateHealthPort | default 8081 }}- protocol: TCP- {{- end }}livenessProbe:httpGet:path: {{ .Values.livenessProbe.path | quote }}- port: {{ if .Values.separateHealthApp }}"health"{{ else }}"http"{{ end }}+ port: "http"initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}periodSeconds: {{ .Values.livenessProbe.periodSeconds }}timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}@@ -192,7 +181,7 @@ spec:readinessProbe:httpGet:path: {{ .Values.readinessProbe.path | quote }}- port: {{ if .Values.separateHealthApp }}"health"{{ else }}"http"{{ end }}+ port: "http"initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}periodSeconds: {{ .Values.readinessProbe.periodSeconds }}timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}@@ -201,7 +190,7 @@ spec:startupProbe:httpGet:path: {{ .Values.startupProbe.path | quote }}- port: {{ if .Values.separateHealthApp }}"health"{{ else }}"http"{{ end }}+ port: "http"initialDelaySeconds: {{ .Values.startupProbe.initialDelaySeconds }}periodSeconds: {{ .Values.startupProbe.periodSeconds }}timeoutSeconds: {{ .Values.startupProbe.timeoutSeconds }}diff --git a/deploy/charts/litellm-helm/values.yaml b/deploy/charts/litellm-helm/values.yamlindex 3dd1112bea7..ba4059e0840 100644--- a/deploy/charts/litellm-helm/values.yaml+++ b/deploy/charts/litellm-helm/values.yaml@@ -88,12 +88,6 @@ service:# optionally specify loadBalancerClass# loadBalancerClass: tailscale-# Separate health app configuration-# When enabled, health checks will use a separate port and the application-# will receive SEPARATE_HEALTH_APP=1 and SEPARATE_HEALTH_PORT from environment variables-separateHealthApp: false-separateHealthPort: 8081-# Probes for LiteLLM gateway containerlivenessProbe:path: /health/livelinessdiff --git a/docker/Dockerfile.database b/docker/Dockerfile.databaseindex 671f374ca27..c84003a065f 100644--- a/docker/Dockerfile.database+++ b/docker/Dockerfile.database@@ -66,7 +66,7 @@ FROM $LITELLM_RUNTIME_IMAGE AS runtimeUSER root-RUN apk add --no-cache bash openssl tzdata nodejs npm python3 libsndfile supervisor && \+RUN apk add --no-cache bash openssl tzdata nodejs npm python3 libsndfile && \npm install -g [email protected] [email protected] [email protected] @isaacs/[email protected] [email protected] [email protected] && \GLOBAL="$(npm root -g)" && \find "$GLOBAL/npm" -type d -name "tar" -path "*/node_modules/tar" | while read d; do \@@ -102,7 +102,5 @@ RUN find /app/.venv -type f -path "*/tornado/test/*" -delete && \EXPOSE 4000/tcp-COPY docker/supervisord.conf /etc/supervisord.conf-ENTRYPOINT ["docker/prod_entrypoint.sh"]CMD ["--port", "4000"]diff --git a/docker/Dockerfile.non_root b/docker/Dockerfile.non_rootindex 3fa73f42437..4de4a55981d 100644--- a/docker/Dockerfile.non_root+++ b/docker/Dockerfile.non_root@@ -103,13 +103,12 @@ RUN for i in 1 2 3; do \apk upgrade --no-cache && break || sleep 5; \done && \for i in 1 2 3; do \- apk add --no-cache python3 bash openssl tzdata supervisor libsndfile nodejs && break || sleep 5; \+ apk add --no-cache python3 bash openssl tzdata libsndfile nodejs && break || sleep 5; \doneCOPY --from=builder /app /appCOPY --from=builder /var/lib/litellm/ui /var/lib/litellm/uiCOPY --from=builder /var/lib/litellm/assets /var/lib/litellm/assets-COPY --from=builder /app/docker/supervisord.conf /etc/supervisord.confENV PATH="/app/.venv/bin:${PATH}" \PRISMA_BINARY_CACHE_DIR=/app/.cache/prisma-python/binaries \diff --git a/docker/prod_entrypoint.sh b/docker/prod_entrypoint.shindex 28d1bdcc294..bd78bf6687b 100644--- a/docker/prod_entrypoint.sh+++ b/docker/prod_entrypoint.sh@@ -1,14 +1,8 @@#!/bin/sh-if [ "$SEPARATE_HEALTH_APP" = "1" ]; then- export LITELLM_ARGS="$@"- export SUPERVISORD_STOPWAITSECS="${SUPERVISORD_STOPWAITSECS:-3600}"- exec supervisord -c /etc/supervisord.conf-fi-if [ "$USE_DDTRACE" = "true" ]; thenexport DD_TRACE_OPENAI_ENABLED="False"exec ddtrace-run litellm "$@"elseexec litellm "$@"-fi\ No newline at end of file+fidiff --git a/docker/supervisord.conf b/docker/supervisord.confdeleted file mode 100644index ba9d99d18a5..00000000000--- a/docker/supervisord.conf+++ /dev/null@@ -1,46 +0,0 @@-[supervisord]-nodaemon=true-loglevel=info-logfile=/tmp/supervisord.log-pidfile=/tmp/supervisord.pid--[group:litellm]-programs=main,health--[program:main]-command=sh -c 'if [ "$USE_DDTRACE" = "true" ]; then export DD_TRACE_OPENAI_ENABLED="False"; exec ddtrace-run python -m litellm.proxy.proxy_cli --host 0.0.0.0 --port=4000 $LITELLM_ARGS; else exec python -m litellm.proxy.proxy_cli --host 0.0.0.0 --port=4000 $LITELLM_ARGS; fi'-autostart=true-autorestart=true-startretries=3-priority=1-exitcodes=0-stopasgroup=true-killasgroup=true-stopwaitsecs=%(ENV_SUPERVISORD_STOPWAITSECS)s-stdout_logfile=/dev/stdout-stderr_logfile=/dev/stderr-stdout_logfile_maxbytes = 0-stderr_logfile_maxbytes = 0-environment=PYTHONUNBUFFERED=true--[program:health]-command=sh -c '[ "$SEPARATE_HEALTH_APP" = "1" ] && exec uvicorn litellm.proxy.health_endpoints.health_app_factory:build_health_app --factory --host 0.0.0.0 --port=${SEPARATE_HEALTH_PORT:-4001} || exit 0'-autostart=true-autorestart=true-startretries=3-priority=2-exitcodes=0-stopasgroup=true-killasgroup=true-stopwaitsecs=%(ENV_SUPERVISORD_STOPWAITSECS)s-stdout_logfile=/dev/stdout-stderr_logfile=/dev/stderr-stdout_logfile_maxbytes = 0-stderr_logfile_maxbytes = 0-environment=PYTHONUNBUFFERED=true--[eventlistener:process_monitor]-command=python -c "from supervisor import childutils; import os, signal; [os.kill(os.getppid(), signal.SIGTERM) for h,p in iter(lambda: childutils.listener.wait(), None) if h['eventname'] in ['PROCESS_STATE_FATAL', 'PROCESS_STATE_EXITED'] and dict([x.split(':') for x in p.split(' ')])['processname'] in ['main', 'health'] or childutils.listener.ok()]"-events=PROCESS_STATE_EXITED,PROCESS_STATE_FATAL-autostart=true-autorestart=true\ No newline at end of filediff --git a/litellm/proxy/health_endpoints/health_app_factory.py b/litellm/proxy/health_endpoints/health_app_factory.pydeleted file mode 100644index c4fe3833650..00000000000--- a/litellm/proxy/health_endpoints/health_app_factory.py+++ /dev/null@@ -1,8 +0,0 @@-from fastapi import FastAPI-from litellm.proxy.health_endpoints._health_endpoints import router as health_router---def build_health_app():- health_app = FastAPI(title="LiteLLM Health Endpoints")- health_app.include_router(health_router)- return health_appdiff --git a/litellm/proxy/proxy_cli.py b/litellm/proxy/proxy_cli.pyindex 90bbfdd25a4..06fc0819a76 100644--- a/litellm/proxy/proxy_cli.py+++ b/litellm/proxy/proxy_cli.py@@ -1050,11 +1050,6 @@ def run_server( # noqa: PLR0915litellm_settings=litellm_settings if config else None, # type: ignore[possibly-unbound])- # --- SEPARATE HEALTH APP LOGIC ---- # To run the health app separately, use:- # uvicorn litellm.proxy.health_app_factory:build_health_app --factory --host 0.0.0.0 --port=4001- # This is compatible with the SEPARATE_HEALTH_APP Docker/supervisord pattern.- # --- END SEPARATE HEALTH APP LOGIC ---# Skip server startup if requested (after all setup is done)if skip_server_startup:print( # noqadiff --git a/tests/test_litellm/proxy/test_proxy_cli.py b/tests/test_litellm/proxy/test_proxy_cli.pyindex f05e95f9e50..59b43330a25 100644--- a/tests/test_litellm/proxy/test_proxy_cli.py+++ b/tests/test_litellm/proxy/test_proxy_cli.py@@ -2,7 +2,6 @@ import osimport sysfrom unittest.mock import MagicMock, patch-import fastapiimport pytestsys.path.insert(@@ -12,7 +11,6 @@ sys.path.insert(import builtinsimport types-from litellm.proxy.health_endpoints.health_app_factory import build_health_appfrom litellm.proxy.proxy_cli import ProxyInitializationHelpers@@ -771,62 +769,8 @@ class TestProxyInitializationHelpers:mock_uvicorn_run.assert_called_once()-class TestHealthAppFactory:- """Test cases for the health app factory module"""-- def test_build_health_app(self):- """Test that build_health_app creates a FastAPI app with the correct title and includes the health router"""- # Execute- health_app = build_health_app()-- # Assert- assert health_app.title == "LiteLLM Health Endpoints"- assert isinstance(health_app, fastapi.FastAPI)-- # Verify that the app has the expected health endpoints by checking route paths- # When a router is included, its routes are flattened into the main app's routes- route_paths = []- for route in health_app.routes:- if hasattr(route, "path"):- route_paths.append(route.path)-- # Check for some expected health endpoints- expected_paths = [- "/test",- "/health/services",- "/health",- "/health/history",- "/health/latest",- "/settings",- "/active/callbacks",- "/health/readiness",- "/health/liveliness",- "/health/liveness",- "/health/test_connection",- ]-- # At least some of the expected health endpoints should be present- found_paths = [path for path in expected_paths if path in route_paths]- assert (- len(found_paths) > 0- ), f"Expected to find health endpoints, but found: {route_paths}"-- # Verify that the app has routes (indicating the router was included)- assert (- len(health_app.routes) > 0- ), "Health app should have routes from the included router"-- def test_build_health_app_returns_different_instances(self):- """Test that build_health_app returns different FastAPI instances on each call"""- # Execute- health_app_1 = build_health_app()- health_app_2 = build_health_app()-- # Assert- assert health_app_1 is not health_app_2- assert health_app_1.title == health_app_2.title- assert isinstance(health_app_1, fastapi.FastAPI)- assert isinstance(health_app_2, fastapi.FastAPI)+class TestRunServerDbSetup:+ """Tests for run_server's prisma setup_database behavior."""@patch("subprocess.run")@patch("atexit.register")