refactor: Web 服务器从 gunicorn 迁移到 uvicorn

This commit is contained in:
qzl
2026-03-06 17:55:01 +08:00
parent b6087fd195
commit 105e7849fe
12 changed files with 108 additions and 22 deletions
+12 -5
View File
@@ -6,7 +6,7 @@ from pathlib import Path
import structlog
from core.config.settings import RuntimeSettings, Settings
from core.config.settings import PROJECT_ROOT, RuntimeSettings, Settings
from core.logging.formatters import (
build_plain_formatter,
build_processor_formatter,
@@ -17,13 +17,20 @@ from core.logging.handlers import build_file_handler_config
def _ensure_log_dirs(runtime: RuntimeSettings) -> None:
Path(runtime.log_dir).mkdir(parents=True, exist_ok=True)
Path(runtime.log_error_dir).mkdir(parents=True, exist_ok=True)
_resolve_log_path(runtime.log_dir).mkdir(parents=True, exist_ok=True)
_resolve_log_path(runtime.log_error_dir).mkdir(parents=True, exist_ok=True)
def _resolve_log_path(path: str) -> Path:
candidate = Path(path)
if candidate.is_absolute():
return candidate
return PROJECT_ROOT / candidate
def build_logging_config(runtime: RuntimeSettings) -> dict[str, object]:
log_dir = Path(runtime.log_dir)
error_dir = Path(runtime.log_error_dir)
log_dir = _resolve_log_path(runtime.log_dir)
error_dir = _resolve_log_path(runtime.log_error_dir)
formatter_name = "json" if runtime.log_json else "plain"
file_handler = build_file_handler_config(