From a806ffcabfb3e8e46599b5090dda009a7cc3f3e4 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Fri, 13 Mar 2026 15:06:09 +0800 Subject: [PATCH] v0.1.4-p2 --- backend/core/settings.py | 18 +++++++++++++----- backend/main.py | 2 ++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/backend/core/settings.py b/backend/core/settings.py index 4b3d999..9a07cef 100644 --- a/backend/core/settings.py +++ b/backend/core/settings.py @@ -5,18 +5,26 @@ from pathlib import Path from typing import Final from urllib.parse import urlsplit, urlunsplit -from dotenv import load_dotenv +from dotenv import dotenv_values, load_dotenv BACKEND_ROOT: Final[Path] = Path(__file__).resolve().parents[1] PROJECT_ROOT: Final[Path] = BACKEND_ROOT.parent # Load env files used by this project. -# Priority (high -> low, with override=False preserving existing values): +# Priority (high -> low): # 1) process environment -# 2) backend/.env -# 3) project/.env.prod +# 2) project/.env.prod +# 3) backend/.env +# +# We keep process-provided env untouched, while allowing .env.prod to override backend/.env. +_process_env_keys = set(os.environ.keys()) load_dotenv(BACKEND_ROOT / ".env", override=False) -load_dotenv(PROJECT_ROOT / ".env.prod", override=False) +for _k, _v in dotenv_values(PROJECT_ROOT / ".env.prod").items(): + if _v is None: + continue + if _k in _process_env_keys: + continue + os.environ[_k] = str(_v) def _env_text(name: str, default: str) -> str: diff --git a/backend/main.py b/backend/main.py index c2ec907..64f3a36 100644 --- a/backend/main.py +++ b/backend/main.py @@ -50,6 +50,7 @@ from core.settings import ( STT_ENABLED, STT_MAX_AUDIO_SECONDS, STT_MODEL, + TOPIC_MCP_INTERNAL_URL, TOPIC_PRESET_TEMPLATES, TOPIC_PRESETS_TEMPLATES_FILE, UPLOAD_MAX_MB, @@ -510,6 +511,7 @@ async def on_startup(): print(f"📁 数据库连接: {DATABASE_URL_DISPLAY}") print(f"🧠 Redis 缓存: {'enabled' if cache.ping() else 'disabled'} ({REDIS_URL if REDIS_ENABLED else 'not configured'})") print(f"🔐 面板访问密码: {'enabled' if str(PANEL_ACCESS_PASSWORD or '').strip() else 'disabled'}") + print(f"🧩 Topic MCP internal URL: {TOPIC_MCP_INTERNAL_URL}") init_database() cache.delete_prefix("") with Session(engine) as session: