This commit is contained in:
2025-11-13 08:19:13 +01:00
parent 17a86c87dc
commit 4830cafd5a
5 changed files with 498 additions and 3 deletions

View File

@@ -14,13 +14,18 @@ from fastapi import FastAPI
BASE_DIR: Path = Path(__file__).resolve().parent
CODE_DIR: Path = BASE_DIR / "code" # .../app/code
CONFIG_DIR: Path = BASE_DIR / "config" # .../app/config
SRC_DIR: Path = BASE_DIR / "src" # .../app/src
# Sicherstellen, dass .../app/code importierbar ist (bevorzugt neue Struktur)
# Sicherstellen, dass .../app/code und .../app/src importierbar sind
if str(CODE_DIR) not in sys.path:
sys.path.insert(0, str(CODE_DIR))
if str(SRC_DIR) not in sys.path:
sys.path.insert(0, str(SRC_DIR))
# Jetzt Import aus neuer Struktur (app/code/app/main.py)
from app.main import create_app # noqa: E402
from src.config_loader import load_runtime_config # noqa: E402
from src.logging_setup import init_logging # noqa: E402
APP_CONFIG_ENV = "APP_CONFIG_PATH"
@@ -88,7 +93,9 @@ def app_factory() -> FastAPI:
Liest Konfiguration, initialisiert Logging und erzeugt die FastAPI-App.
"""
cfg = load_config_from_env()
setup_logging(cfg)
# Laufzeit-Settings laden und Logging initialisieren (überschreibt ggf. YAML-Logging)
settings = load_runtime_config(base_dir=BASE_DIR)
init_logging(settings)
app = create_app(cfg)
return app
@@ -126,7 +133,9 @@ def main(argv: Optional[List[str]] = None) -> None:
os.environ[APP_CONFIG_ENV] = str(config_path)
cfg = load_yaml(config_path)
setup_logging(cfg)
# Laufzeit-Settings laden und Logging initialisieren (überschreibt ggf. YAML-Logging)
settings = load_runtime_config(base_dir=BASE_DIR)
init_logging(settings)
app_cfg = cfg.get("app", {}) or {}
host = str(app_cfg.get("host", "0.0.0.0"))