2026-03-09 14:05:00 +08:00
|
|
|
"""
|
|
|
|
|
Configuration for Task Scheduler Service
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
from typing import List
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
|
"""Task Scheduler settings"""
|
|
|
|
|
|
2026-03-18 09:19:29 +08:00
|
|
|
# Celery settings — 从环境变量 REDIS_URL 派生
|
|
|
|
|
CELERY_BROKER_URL: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
|
|
|
|
CELERY_RESULT_BACKEND: str = os.getenv("REDIS_URL", "redis://localhost:6379/0")
|
2026-03-09 14:05:00 +08:00
|
|
|
|
|
|
|
|
# Task execution settings
|
|
|
|
|
MAX_CONCURRENT_TASKS: int = int(os.getenv("MAX_CONCURRENT_TASKS", "10"))
|
|
|
|
|
TASK_TIMEOUT_SECONDS: int = int(os.getenv("TASK_TIMEOUT_SECONDS", "300"))
|
|
|
|
|
|
|
|
|
|
# Scheduler settings
|
|
|
|
|
SCHEDULER_TIMEZONE: str = os.getenv("SCHEDULER_TIMEZONE", "Asia/Shanghai")
|
|
|
|
|
BEAT_SCHEDULE_FILE: str = os.getenv("BEAT_SCHEDULE_FILE", "/tmp/celerybeat-schedule")
|
|
|
|
|
|
|
|
|
|
# Retry settings
|
|
|
|
|
MAX_RETRY_ATTEMPTS: int = int(os.getenv("MAX_RETRY_ATTEMPTS", "3"))
|
|
|
|
|
RETRY_DELAY_SECONDS: int = int(os.getenv("RETRY_DELAY_SECONDS", "60"))
|
|
|
|
|
|
|
|
|
|
# Logging
|
|
|
|
|
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO")
|
|
|
|
|
DEBUG: bool = os.getenv("DEBUG", "False").lower() == "true"
|
|
|
|
|
|
|
|
|
|
# Service URLs
|
|
|
|
|
SIGNIN_EXECUTOR_URL: str = os.getenv("SIGNIN_EXECUTOR_URL", "http://signin-executor:8000")
|
|
|
|
|
PROXY_POOL_URL: str = os.getenv("PROXY_POOL_URL", "http://proxy-pool:8080")
|
|
|
|
|
BROWSER_AUTOMATION_URL: str = os.getenv("BROWSER_AUTOMATION_URL", "http://browser-automation:3001")
|
|
|
|
|
|
2026-03-09 16:10:29 +08:00
|
|
|
# Redis pub/sub settings for task updates
|
|
|
|
|
REDIS_TASK_CHANNEL: str = os.getenv("REDIS_TASK_CHANNEL", "task_updates")
|
|
|
|
|
|
2026-03-09 14:05:00 +08:00
|
|
|
class Config:
|
|
|
|
|
case_sensitive = True
|
|
|
|
|
env_file = ".env"
|
2026-03-18 09:19:29 +08:00
|
|
|
extra = "ignore"
|
2026-03-09 14:05:00 +08:00
|
|
|
|
|
|
|
|
settings = Settings()
|