schon/evibes/settings/celery.py
Egor fureunoir Gorbunov bf6b9f4424 Features: 1) Add backup_task to manage database and media backups; 2) Introduce periodic scheduling for backup_task via Celery Beat;
Fixes: 1) Apply `--omit` filter for test coverage reports to exclude unnecessary files; 2) Replace `services_data` volume mounts with named Docker volumes for consistency and cleanup (e.g., `postgres-data`, `redis-data`);

Extra: 1) Remove `services_data` from `.gitignore`, Docker-related cleanup in uninstall scripts; 2) Simplified related files removal scripts for Unix and Windows; 3) Minor adjustments in documentation comments.
2025-11-13 17:14:00 +03:00

58 lines
1.8 KiB
Python

from datetime import timedelta
from evibes.settings.base import REDIS_PASSWORD, TIME_ZONE
CELERY_ENABLE_UTC = False
CELERY_TIMEZONE = TIME_ZONE
CELERY_BROKER_URL = f"redis://:{REDIS_PASSWORD}@redis:6379/0"
CELERY_BROKER_HEARTBEAT = 10
CELERY_BROKER_HEARTBEAT_CHECKRATE = 2
CELERY_BROKER_POOL_LIMIT = 10
CELERY_BROKER_TRANSPORT_OPTIONS = {
"visibility_timeout": 3600,
"retry_policy": {"interval_start": 0.1, "interval_step": 0.2, "max_retries": 5},
"socket_keepalive": True,
"socket_timeout": 30,
"socket_connect_timeout": 30,
"retry_on_timeout": True,
}
CELERY_RESULT_BACKEND = CELERY_BROKER_URL
CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers.DatabaseScheduler"
CELERY_BEAT_SCHEDULE = {
"backup_task": {
"task": "engine.core.tasks.backup_task",
"schedule": timedelta(days=7),
"options": {"queue": "default"},
},
"update_products_task": {
"task": "engine.core.tasks.update_products_task",
"schedule": timedelta(minutes=60),
"options": {"queue": "stock_updater"},
},
"update_orderproducts_task": {
"task": "engine.core.tasks.update_orderproducts_task",
"schedule": timedelta(minutes=1),
"options": {"queue": "default"},
},
"set_default_caches_task": {
"task": "engine.core.tasks.set_default_caches_task",
"schedule": timedelta(hours=4),
"options": {"queue": "default"},
},
"remove_stale_product_images": {
"task": "engine.core.tasks.remove_stale_product_images",
"schedule": timedelta(days=1),
"options": {"queue": "default"},
},
"process_promotions": {
"task": "engine.core.tasks.process_promotions",
"schedule": timedelta(hours=2),
"options": {"queue": "default"},
},
}