47 lines
1.3 KiB
Python
47 lines
1.3 KiB
Python
|
|
"""
|
||
|
|
System Router
|
||
|
|
Health checks and system information
|
||
|
|
"""
|
||
|
|
|
||
|
|
from fastapi import APIRouter
|
||
|
|
from app.core.config import settings
|
||
|
|
from app.core.database import execute_query
|
||
|
|
|
||
|
|
router = APIRouter()
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/system/health")
|
||
|
|
async def health_check():
|
||
|
|
"""Comprehensive health check"""
|
||
|
|
try:
|
||
|
|
# Test database connection
|
||
|
|
result = execute_query("SELECT 1 as test")
|
||
|
|
db_status = "healthy" if result else "unhealthy"
|
||
|
|
except Exception as e:
|
||
|
|
db_status = f"unhealthy: {str(e)}"
|
||
|
|
|
||
|
|
return {
|
||
|
|
"status": "healthy",
|
||
|
|
"service": "BMC Hub",
|
||
|
|
"version": "1.0.0",
|
||
|
|
"database": db_status,
|
||
|
|
"config": {
|
||
|
|
"environment": "production" if not settings.ECONOMIC_DRY_RUN else "development",
|
||
|
|
"economic_read_only": settings.ECONOMIC_READ_ONLY,
|
||
|
|
"economic_dry_run": settings.ECONOMIC_DRY_RUN
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/system/config")
|
||
|
|
async def get_config():
|
||
|
|
"""Get system configuration (non-sensitive)"""
|
||
|
|
return {
|
||
|
|
"api_host": settings.API_HOST,
|
||
|
|
"api_port": settings.API_PORT,
|
||
|
|
"log_level": settings.LOG_LEVEL,
|
||
|
|
"economic_enabled": bool(settings.ECONOMIC_APP_SECRET_TOKEN),
|
||
|
|
"economic_read_only": settings.ECONOMIC_READ_ONLY,
|
||
|
|
"economic_dry_run": settings.ECONOMIC_DRY_RUN
|
||
|
|
}
|