Initial commit: scheduler service extraction from portainer-core
Build and Push / build (release) Failing after 17s
Build and Push / build (release) Failing after 17s
Extracted standalone scheduler service with: - FastAPI REST API for task management - APScheduler-based task execution - PostgreSQL persistence - Docker container support - Gitea Actions CI/CD workflow 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
"""
|
||||
Configuration management for The Scheduler.
|
||||
Uses Pydantic BaseSettings for type-safe environment variable loading.
|
||||
"""
|
||||
from functools import lru_cache
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import Field
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings loaded from environment variables."""
|
||||
|
||||
# Application
|
||||
app_name: str = Field(default="The Scheduler", alias="APP_NAME")
|
||||
app_version: str = Field(default="1.0.0", alias="APP_VERSION")
|
||||
debug: bool = Field(default=False, alias="DEBUG")
|
||||
host: str = Field(default="0.0.0.0", alias="HOST")
|
||||
port: int = Field(default=8090, alias="PORT")
|
||||
log_level: str = Field(default="INFO", alias="LOG_LEVEL")
|
||||
|
||||
# Security
|
||||
scheduler_api_key: str = Field(default="dev-key-change-me", alias="SCHEDULER_API_KEY")
|
||||
|
||||
# PostgreSQL
|
||||
postgres_host: str = Field(default="postgres-shared", alias="POSTGRES_HOST")
|
||||
postgres_port: int = Field(default=5432, alias="POSTGRES_PORT")
|
||||
postgres_db: str = Field(default="library_scheduler", alias="POSTGRES_DB")
|
||||
postgres_user: str = Field(default="library_scheduler_user", alias="POSTGRES_USER")
|
||||
postgres_password: str = Field(default="", alias="POSTGRES_PASSWORD")
|
||||
|
||||
# Redis
|
||||
redis_host: str = Field(default="redis-shared", alias="REDIS_HOST")
|
||||
redis_port: int = Field(default=6379, alias="REDIS_PORT")
|
||||
redis_db: int = Field(default=3, alias="REDIS_DB")
|
||||
|
||||
# Gitea
|
||||
gitea_url: str = Field(default="http://gitea:3000", alias="GITEA_URL")
|
||||
gitea_user: str = Field(default="library", alias="GITEA_USER")
|
||||
gitea_password: str = Field(default="", alias="GITEA_PASSWORD")
|
||||
gitea_ssh_host: str = Field(default="gitea", alias="GITEA_SSH_HOST")
|
||||
gitea_ssh_port: int = Field(default=22, alias="GITEA_SSH_PORT")
|
||||
|
||||
# Backup Configuration
|
||||
backup_retention_daily: int = Field(default=7, alias="BACKUP_RETENTION_DAILY")
|
||||
backup_retention_weekly: int = Field(default=4, alias="BACKUP_RETENTION_WEEKLY")
|
||||
backup_retention_monthly: int = Field(default=12, alias="BACKUP_RETENTION_MONTHLY")
|
||||
|
||||
# Documentation Mirroring
|
||||
docs_mirror_path: str = Field(default="/docs-mirror", alias="DOCS_MIRROR_PATH")
|
||||
docs_check_interval: int = Field(default=21600, alias="DOCS_CHECK_INTERVAL") # 6 hours
|
||||
|
||||
@property
|
||||
def database_url(self) -> str:
|
||||
"""PostgreSQL connection URL for APScheduler."""
|
||||
return f"postgresql://{self.postgres_user}:{self.postgres_password}@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
|
||||
|
||||
@property
|
||||
def redis_url(self) -> str:
|
||||
"""Redis connection URL."""
|
||||
return f"redis://{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
case_sensitive = False
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
"""
|
||||
Get cached settings instance.
|
||||
Using lru_cache ensures we only create one Settings instance.
|
||||
"""
|
||||
return Settings()
|
||||
Reference in New Issue
Block a user