将ProjectConfig加入Architecture

This commit is contained in:
2025-11-07 23:47:33 +08:00
parent c49f55808e
commit 9899387697
8 changed files with 56 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
"""健康检查路由"""
from ..Convention.Runtime.Config import *
from ..Convention.Runtime.Architecture import Architecture
try:
import psutil
except ImportError:
@@ -10,17 +11,16 @@ from fastapi.responses import JSONResponse
from ..CoreModules.database import get_db
from ..Convention.Runtime.GlobalConfig import ProjectConfig, ConsoleFrontColor
config = ProjectConfig()
logger: ProjectConfig = Architecture.Get(ProjectConfig)
router = APIRouter()
@router.get("/health")
async def health_check():
"""健康检查"""
return JSONResponse({
"status": "healthy",
"service": config.FindItem("app_name", "Application")
"service": logger.FindItem("app_name", "Application")
})
@@ -53,9 +53,10 @@ async def system_stats():
}
})
except Exception as e:
config.Log("Error", f"{ConsoleFrontColor.RED}获取系统统计失败: {e}{ConsoleFrontColor.RESET}")
logger.Log("Error", f"{ConsoleFrontColor.RED}获取系统统计失败: {e}{ConsoleFrontColor.RESET}")
return JSONResponse(
status_code=500,
content={"error": str(e)}
)
logger.SaveProperties()