bd21b05fbc
- 删除 src/utils/prewarm_dashboard.py - 删除 scripts/prewarm_dashboard_cache.py、prewarm_dashboard_worker.py - docker-compose.yml 移除 polyweather_prewarm 服务 - runtime_coordinator.py 移除预热循环启动逻辑 - web/core.py 移除 prewarm status 上报 - web/routers/system.py 移除 /api/system/prewarm 端点 - web/services/system_api.py 移除 run_system_prewarm - city_runtime.py DEFAULT_PREWARM_CITIES 改名为 DEFAULT_STATUS_CITIES - 清理 env.example、测试、VPS .env 中的预热配置
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""System and observability API routes for PolyWeather."""
|
|
|
|
from typing import Optional
|
|
|
|
from fastapi import APIRouter, BackgroundTasks, Request
|
|
from fastapi.responses import PlainTextResponse
|
|
|
|
from web.services.dashboard_init_api import build_dashboard_init_payload
|
|
from web.services.system_api import (
|
|
get_health_payload,
|
|
get_prometheus_metrics_response,
|
|
get_system_cache_status,
|
|
get_system_status_payload,
|
|
run_system_priority_warm,
|
|
)
|
|
|
|
router = APIRouter(tags=["system"])
|
|
|
|
|
|
@router.get("/healthz")
|
|
async def healthz():
|
|
return get_health_payload()
|
|
|
|
|
|
@router.get("/api/system/status")
|
|
async def system_status():
|
|
return await get_system_status_payload()
|
|
|
|
|
|
@router.get("/api/system/cache-status")
|
|
async def system_cache_status(request: Request, cities: Optional[str] = None):
|
|
return get_system_cache_status(request, cities=cities)
|
|
|
|
|
|
@router.post("/api/system/priority-warm")
|
|
async def system_priority_warm(
|
|
request: Request,
|
|
background_tasks: BackgroundTasks,
|
|
timezone: Optional[str] = None,
|
|
):
|
|
return run_system_priority_warm(request, background_tasks, timezone=timezone)
|
|
|
|
|
|
@router.get("/metrics", response_class=PlainTextResponse)
|
|
async def metrics():
|
|
return get_prometheus_metrics_response()
|
|
|
|
|
|
@router.get("/api/dashboard/init")
|
|
async def dashboard_init(request: Request):
|
|
return await build_dashboard_init_payload(request)
|