| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- from functools import lru_cache
- from pydantic_settings import BaseSettings, SettingsConfigDict
- from pydantic import Field
- class Settings(BaseSettings):
- # -----------------------
- # App
- # -----------------------
- app_name: str = "MyApp"
- env: str = "PROD"
- debug: bool = False
- # -----------------------
- # Database / Cache
- # -----------------------
- database_url: str = Field(..., description="Async database DSN")
- redis_url: str
- # -----------------------
- # Security / API Keys
- # -----------------------
- openai_api_key: str
- stripe_api_key: str
- # -----------------------
- # Remote Servers
- # -----------------------
- remote_servers: dict = {
- "MCP1": {
- "host": "45.137.220.138",
- "port": 22,
- "username": "root",
- "password": "s3UqbkWxW72",
- "project_path": "/root/troov-asyncio"
- },
- "MCP2": {
- "host": "185.148.147.103",
- "port": 22,
- "username": "root",
- "password": "nBEqFzWe7z7pbprypmUt",
- "project_path": "/root/troov-asyncio"
- },
- "MCP3": {
- "host": "185.148.147.119",
- "port": 22,
- "username": "root",
- "password": "5hcm07IAnBAv87Ey",
- "project_path": "/root/troov-asyncio"
- }
- }
- model_config = SettingsConfigDict(
- env_file=".env",
- env_file_encoding="utf-8",
- case_sensitive=False,
- )
- @lru_cache
- def get_settings() -> Settings:
- """
- 避免多次实例化 Settings(FastAPI 官方推荐)
- """
- return Settings()
- settings = get_settings()
- # -----------------------
- # Global constants
- # -----------------------
- BASE_CURRENCY = "EUR"
|