File size: 617 Bytes
2648369
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
@app.get("/health")
async def health_check():
    """Check the health of the API and its dependencies."""
    docker_health = check_docker_health()
    gpu_status = check_gpu_availability()
    
    health_status = {
        "status": "healthy" if docker_health["status"] == "healthy" else "unhealthy",
        "docker": docker_health,
        "gpu": gpu_status,
        "api_version": "1.0.0"
    }
    
    status_code = 200 if health_status["status"] == "healthy" else 503
    return Response(
        content=json.dumps(health_status),
        media_type="application/json",
        status_code=status_code
    )