- 4개 검사 엔진: HTML/CSS, 접근성(WCAG), SEO, 성능/보안 (총 50개 항목) - FastAPI 백엔드 (9개 API, SSE 실시간 진행, PDF/JSON 리포트) - Next.js 15 프론트엔드 (6개 페이지, 29개 컴포넌트, 반원 게이지 차트) - Docker Compose 배포 (Backend:8011, Frontend:3011, MongoDB:27022, Redis:6392) - 전체 테스트 32/32 PASS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
"""
|
|
Health check router.
|
|
GET /api/health
|
|
"""
|
|
|
|
import logging
|
|
from datetime import datetime, timezone
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.core.database import get_db
|
|
from app.core.redis import get_redis
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
async def health_check():
|
|
"""Check system health including MongoDB and Redis connectivity."""
|
|
services = {}
|
|
|
|
# Check MongoDB
|
|
try:
|
|
db = get_db()
|
|
await db.command("ping")
|
|
services["mongodb"] = "connected"
|
|
except Exception as e:
|
|
logger.error("MongoDB health check failed: %s", str(e))
|
|
services["mongodb"] = "disconnected"
|
|
|
|
# Check Redis
|
|
try:
|
|
redis = get_redis()
|
|
await redis.ping()
|
|
services["redis"] = "connected"
|
|
except Exception as e:
|
|
logger.error("Redis health check failed: %s", str(e))
|
|
services["redis"] = "disconnected"
|
|
|
|
# Overall status
|
|
all_connected = all(v == "connected" for v in services.values())
|
|
status = "healthy" if all_connected else "degraded"
|
|
|
|
return {
|
|
"status": status,
|
|
"timestamp": datetime.now(timezone.utc).isoformat(),
|
|
"services": services,
|
|
}
|