Add helper functions for HealthCheck

This commit is contained in:
Backend IM Bot 2025-03-27 13:40:39 -05:00
parent ca35ae5e24
commit 4742dd9c34

View File

@ -0,0 +1,48 @@
from fastapi import APIRouter, status
from datetime import datetime
router = APIRouter()
@router.get("/api/health", status_code=status.HTTP_200_OK)
def health_check():
"""
Health check endpoint to verify service status.
Returns:
dict: JSON response indicating service is running.
"""
response = {
"status": "ok",
"message": "Service is running",
"timestamp": datetime.utcnow().isoformat()
}
return response
def is_service_running() -> bool:
"""
Check if the service is running.
Returns:
bool: True if the service is running, False otherwise.
"""
# Add any necessary checks or logic here
return True
def get_service_uptime() -> float:
"""
Get the service uptime in seconds.
Returns:
float: Service uptime in seconds.
"""
# Add logic to calculate service uptime
return 3600.0 # Example: 1 hour uptime
def get_service_version() -> str:
"""
Get the current service version.
Returns:
str: Service version string.
"""
return "1.0.0" # Example version