Files
mirror/app/config.py
T
mohammadian7 63d0699cdd Fix Docker apply crash and add safe profile test flow
Remove invalid _mirror_manager from daemon.json that prevented Docker from starting. Add 2-minute test apply with auto-rollback, final apply confirmation, emergency-restore CLI/UI, and post-restart Docker health checks.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-10 20:20:10 +03:30

36 lines
1.2 KiB
Python

import os
from pathlib import Path
class Config:
SECRET_KEY = os.environ.get("SECRET_KEY", "dev-secret-change-in-production")
SQLALCHEMY_DATABASE_URI = os.environ.get(
"DATABASE_URL",
f"sqlite:///{Path(os.environ.get('DATA_DIR', 'data')).resolve() / 'mirror.db'}",
)
SQLALCHEMY_TRACK_MODIFICATIONS = False
ADMIN_USERNAME = os.environ.get("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD = os.environ.get("ADMIN_PASSWORD", "admin")
DATA_DIR = Path(os.environ.get("DATA_DIR", "data"))
BACKUP_DIR = DATA_DIR / "backups"
HOST_ROOT = os.environ.get("HOST_ROOT", "")
ROLLBACK_MINUTES = int(os.environ.get("ROLLBACK_MINUTES", "15"))
TEST_ROLLBACK_MINUTES = int(os.environ.get("TEST_ROLLBACK_MINUTES", "2"))
AUTO_TEST_INTERVAL_MINUTES = int(os.environ.get("AUTO_TEST_INTERVAL_MINUTES", "30"))
RESOLVED_DROPIN = "mirror-manager.conf"
RESOLVED_DROPIN_DIR = "resolved.conf.d"
GIT_CONFIG_GLOBAL = Path.home() / ".gitconfig"
@classmethod
def host_path(cls, *parts: str) -> Path:
return Path(cls.HOST_ROOT).joinpath(*parts)
@classmethod
def ensure_dirs(cls) -> None:
cls.DATA_DIR.mkdir(parents=True, exist_ok=True)
cls.BACKUP_DIR.mkdir(parents=True, exist_ok=True)