ipmi-fan-control/backend/config.py

48 lines
1.4 KiB
Python

"""Application configuration."""
import os
from pathlib import Path
from pydantic_settings import BaseSettings
from pydantic import Field
BASE_DIR = Path(__file__).parent
DATA_DIR = Path(os.getenv("DATA_DIR", "/app/data"))
DATA_DIR.mkdir(parents=True, exist_ok=True)
class Settings(BaseSettings):
"""Application settings."""
# Security
SECRET_KEY: str = Field(default="change-me-in-production", description="Secret key for JWT")
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
# Database
DATABASE_URL: str = Field(default=f"sqlite:///{DATA_DIR}/ipmi_fan_control.db")
# IPMI Settings
IPMITOOL_PATH: str = Field(default="ipmitool", description="Path to ipmitool binary")
PANIC_TIMEOUT_SECONDS: int = Field(default=60, description="Seconds without sensor data before panic mode")
PANIC_FAN_SPEED: int = Field(default=100, description="Fan speed during panic mode")
# Fan Control Settings
DEFAULT_FAN_CURVE: list = Field(default=[
{"temp": 30, "speed": 10},
{"temp": 40, "speed": 20},
{"temp": 50, "speed": 35},
{"temp": 60, "speed": 50},
{"temp": 70, "speed": 70},
{"temp": 80, "speed": 100},
])
# App Settings
APP_NAME: str = "IPMI Fan Control"
DEBUG: bool = False
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
settings = Settings()