32 lines
806 B
Python
32 lines
806 B
Python
|
|
import logging
|
||
|
|
import os
|
||
|
|
|
||
|
|
import psutil
|
||
|
|
from fastapi import APIRouter
|
||
|
|
|
||
|
|
from app.schemas.system import HealthResponse, SystemInfoResponse
|
||
|
|
from app.services import freepik_client, task_tracker
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
router = APIRouter(prefix='/api/v1', tags=['system'])
|
||
|
|
|
||
|
|
|
||
|
|
@router.get('/health', response_model=HealthResponse)
|
||
|
|
async def health_check():
|
||
|
|
return HealthResponse()
|
||
|
|
|
||
|
|
|
||
|
|
@router.get('/system', response_model=SystemInfoResponse)
|
||
|
|
async def system_info():
|
||
|
|
api_key_valid = await freepik_client.check_api_key()
|
||
|
|
mem = psutil.virtual_memory()
|
||
|
|
|
||
|
|
return SystemInfoResponse(
|
||
|
|
api_key_valid=api_key_valid,
|
||
|
|
active_tasks=task_tracker.active_count(),
|
||
|
|
cpu_count=os.cpu_count() or 1,
|
||
|
|
memory_total=mem.total,
|
||
|
|
memory_available=mem.available,
|
||
|
|
)
|