v0.1.4-p2
parent
fe066f19fe
commit
a806ffcabf
|
|
@ -5,18 +5,26 @@ from pathlib import Path
|
||||||
from typing import Final
|
from typing import Final
|
||||||
from urllib.parse import urlsplit, urlunsplit
|
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]
|
BACKEND_ROOT: Final[Path] = Path(__file__).resolve().parents[1]
|
||||||
PROJECT_ROOT: Final[Path] = BACKEND_ROOT.parent
|
PROJECT_ROOT: Final[Path] = BACKEND_ROOT.parent
|
||||||
|
|
||||||
# Load env files used by this project.
|
# Load env files used by this project.
|
||||||
# Priority (high -> low, with override=False preserving existing values):
|
# Priority (high -> low):
|
||||||
# 1) process environment
|
# 1) process environment
|
||||||
# 2) backend/.env
|
# 2) project/.env.prod
|
||||||
# 3) 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(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:
|
def _env_text(name: str, default: str) -> str:
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ from core.settings import (
|
||||||
STT_ENABLED,
|
STT_ENABLED,
|
||||||
STT_MAX_AUDIO_SECONDS,
|
STT_MAX_AUDIO_SECONDS,
|
||||||
STT_MODEL,
|
STT_MODEL,
|
||||||
|
TOPIC_MCP_INTERNAL_URL,
|
||||||
TOPIC_PRESET_TEMPLATES,
|
TOPIC_PRESET_TEMPLATES,
|
||||||
TOPIC_PRESETS_TEMPLATES_FILE,
|
TOPIC_PRESETS_TEMPLATES_FILE,
|
||||||
UPLOAD_MAX_MB,
|
UPLOAD_MAX_MB,
|
||||||
|
|
@ -510,6 +511,7 @@ async def on_startup():
|
||||||
print(f"📁 数据库连接: {DATABASE_URL_DISPLAY}")
|
print(f"📁 数据库连接: {DATABASE_URL_DISPLAY}")
|
||||||
print(f"🧠 Redis 缓存: {'enabled' if cache.ping() else 'disabled'} ({REDIS_URL if REDIS_ENABLED else 'not configured'})")
|
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"🔐 面板访问密码: {'enabled' if str(PANEL_ACCESS_PASSWORD or '').strip() else 'disabled'}")
|
||||||
|
print(f"🧩 Topic MCP internal URL: {TOPIC_MCP_INTERNAL_URL}")
|
||||||
init_database()
|
init_database()
|
||||||
cache.delete_prefix("")
|
cache.delete_prefix("")
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue