更新内容: - 移除 `dashboard.json` 文件,清理不再需要的 Grafana 仪表板配置。 - 简化项目目录结构,删除多余的监控配置以优化维护。
63 lines
1.6 KiB
Python
63 lines
1.6 KiB
Python
"""配置管理模块"""
|
|
|
|
from pydantic_settings import BaseSettings
|
|
from pydantic import ConfigDict
|
|
from typing import Optional
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""应用配置"""
|
|
|
|
model_config = ConfigDict(env_file=".env", case_sensitive=False)
|
|
|
|
# 应用信息
|
|
app_name: str = "FunctionalScaffold"
|
|
app_version: str = "1.0.0"
|
|
app_env: str = "development"
|
|
|
|
# 服务器配置
|
|
host: str = "0.0.0.0"
|
|
port: int = 8000
|
|
workers: int = 4
|
|
|
|
# 日志配置
|
|
log_level: str = "INFO"
|
|
log_format: str = "json"
|
|
log_file_enabled: bool = False
|
|
log_file_path: str = "/var/log/app/app.log"
|
|
|
|
# 指标配置
|
|
metrics_enabled: bool = True
|
|
|
|
# 追踪配置
|
|
tracing_enabled: bool = False
|
|
jaeger_endpoint: Optional[str] = None
|
|
|
|
# 外部服务配置(示例)
|
|
oss_endpoint: Optional[str] = None
|
|
oss_access_key_id: Optional[str] = None
|
|
oss_access_key_secret: Optional[str] = None
|
|
oss_bucket_name: Optional[str] = None
|
|
|
|
database_url: Optional[str] = None
|
|
|
|
# Redis 配置
|
|
redis_host: str = "localhost"
|
|
redis_port: int = 6379
|
|
redis_db: int = 0
|
|
redis_password: Optional[str] = None
|
|
|
|
# 指标配置
|
|
metrics_config_path: str = "config/metrics.yaml"
|
|
metrics_instance_id: Optional[str] = None # 默认使用 hostname
|
|
|
|
# 异步任务配置
|
|
job_result_ttl: int = 1800 # 结果缓存时间(秒),默认 30 分钟
|
|
webhook_max_retries: int = 3 # Webhook 最大重试次数
|
|
webhook_timeout: int = 10 # Webhook 超时时间(秒)
|
|
max_concurrent_jobs: int = 10 # 最大并发任务数
|
|
|
|
|
|
# 全局配置实例
|
|
settings = Settings()
|