fix(dev): improve gateway startup diagnostics for config errors (#1020)

This commit is contained in:
Willem Jiang
2026-03-08 21:06:57 +08:00
committed by GitHub
parent cf9af1fe75
commit 6b5c4fe6dd
4 changed files with 26 additions and 5 deletions

View File

@@ -1,5 +1,4 @@
import logging
import sys
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
@@ -38,8 +37,9 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
get_app_config()
logger.info("Configuration loaded successfully")
except Exception as e:
logger.error(f"Failed to load configuration: {e}")
sys.exit(1)
error_msg = f"Failed to load configuration during gateway startup: {e}"
logger.exception(error_msg)
raise RuntimeError(error_msg) from e
config = get_gateway_config()
logger.info(f"Starting API Gateway on {config.host}:{config.port}")