Skip to main content

Configuration model

Celery Root is configured with Pydantic models. Components are enabled when their config is provided (set to None to disable).
from pathlib import Path

from celery_root import (
    BeatConfig,
    CeleryRootConfig,
    DatabaseConfigSqlite,
    FrontendConfig,
    LoggingConfigFile,
    OpenTelemetryConfig,
    PrometheusConfig,
)

config = CeleryRootConfig(
    logging=LoggingConfigFile(log_dir=Path("./logs")),
    database=DatabaseConfigSqlite(db_path=Path("./celery_root.db")),
    beat=BeatConfig(schedule_path=Path("./celerybeat-schedule")),
    prometheus=PrometheusConfig(port=8001, prometheus_path="/metrics"),
    open_telemetry=OpenTelemetryConfig(endpoint="http://localhost:4317"),
    frontend=FrontendConfig(host="127.0.0.1", port=8000),
)

Worker import paths

Celery Root needs import paths to your Celery apps:
export CELERY_ROOT_WORKERS="your_app.celery:app,another_app.celery:app"
Worker import paths are resolved in this order:
  • config.worker_import_paths
  • CELERY_ROOT_WORKERS
  • Paths derived from the Celery apps you pass in

Database settings (SQLite)

DatabaseConfigSqlite controls the local store:
  • db_path: SQLite file path.
  • retention_days: Record retention window (cleanup runs periodically).
  • batch_size: Max events per flush.
  • flush_interval: Seconds between flushes.
  • purge_db: Delete the file on startup.

Logging settings

LoggingConfigFile controls log output:
  • log_dir: Directory for log files.
  • log_rotation_hours: File rotation interval.
  • log_level: Log level string.
  • delete_on_boot: Delete logs on startup.

Frontend settings

FrontendConfig controls the UI server:
  • host, port, debug, poll_interval.
  • secret_key: Django secret key.
  • basic_auth: Basic auth users (see Auth guide).
  • OAuth fields: auth_provider, auth, oauth2_key, oauth2_secret, oauth2_redirect_uri.
  • GitLab/Okta fields: oauth2_okta_base_url, gitlab_allowed_groups, gitlab_min_access_level, gitlab_oauth_domain.

Metrics settings

  • PrometheusConfig: port, path, and Flower metric naming compatibility.
  • OpenTelemetryConfig: OTLP endpoint and service name.

MCP settings

McpConfig enables the MCP server. See the MCP guide for details.

Overriding settings early

If you need settings applied before Django loads:
from celery_root.config import set_settings

set_settings(config)