-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python code
Description
Description
Currently, the FastAPI app does not expose a dedicated /health endpoint for health checking. Adding this endpoint will improve container orchestration support (e.g., Docker, Kubernetes), enabling external systems to verify if the service is alive and responsive.
Suggested Approach
Implement a simple GET /health endpoint returning a JSON response such as {"status": "ok"} with HTTP status 200. This endpoint should be lightweight and not depend on external services to respond quickly.
Proposed Implementation
health_route.py
from fastapi import APIRouter
api_router = APIRouter()
@api_router.get("/health", tags=["Health"])
async def health_check():
"""
Simple health check endpoint. Returns a JSON response with a single key "status" and value "ok".
"""
return {"status": "ok"}main.py
app.include_router(health_route.api_router)healthcheck.sh
#!/bin/sh
set -e
# Simple health check using curl
curl --fail http://localhost:9000/healthDockerfile
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD ["./healthcheck.sh"]Acceptance Criteria
- A
/healthendpoint is accessible and returnsHTTP 200with{"status": "ok"}JSON. - The endpoint responds quickly without depending on database or external services.
- Automated tests cover the new endpoint.
Dockerfileincludes a workingHEALTHCHECKreferencing the/healthendpoint.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomerspythonPull requests that update Python codePull requests that update Python code