From a4a63bd31f96803d78a02bf08db2a87dc8e9ee80 Mon Sep 17 00:00:00 2001 From: NikDizell Date: Fri, 19 Jun 2026 18:29:44 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BE=D0=BA=20=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OneCprogsite/__init__.py | 4 ++++ OneCprogsite/celery.py | 9 +++++++++ OneCprogsite/settings.py | 14 +++++++++++--- requirements.txt | 5 ++++- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 OneCprogsite/celery.py diff --git a/OneCprogsite/__init__.py b/OneCprogsite/__init__.py index e69de29..3802616 100644 --- a/OneCprogsite/__init__.py +++ b/OneCprogsite/__init__.py @@ -0,0 +1,4 @@ +from .celery import app as celery_app + + +__all__ = ('celery_app',) diff --git a/OneCprogsite/celery.py b/OneCprogsite/celery.py new file mode 100644 index 0000000..c0986a8 --- /dev/null +++ b/OneCprogsite/celery.py @@ -0,0 +1,9 @@ +import os +from celery import Celery + + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'OneCprogsite.settings') + +app = Celery('OneCprogsite') +app.config_from_object('django.conf:settings', namespace='CELERY') +app.autodiscover_tasks() diff --git a/OneCprogsite/settings.py b/OneCprogsite/settings.py index 0939a3e..284625b 100644 --- a/OneCprogsite/settings.py +++ b/OneCprogsite/settings.py @@ -70,9 +70,16 @@ if not DEBUG: LANGUAGE_COOKIE_HTTPONLY = True LANGUAGE_COOKIE_SAMESITE = 'Lax' - # Redis - CELERY_BROKER_URL = os.environ.get('CELERY_BROKER_URL', 'redis://localhost:6379/0') - CELERY_RESULT_BACKEND = os.environ.get('CELERY_RESULT_BACKEND', 'redis://localhost:6379/0') + # Celery + CELERY_BROKER_URL = os.environ.get('REDIS_URL', 'redis://redis:6379/0') + CELERY_RESULT_BACKEND = os.environ.get('REDIS_URL', 'redis://redis:6379/0') + CELERY_ACCEPT_CONTENT = ['json'] + CELERY_TASK_SERIALIZER = 'json' + CELERY_RESULT_SERIALIZER = 'json' + CELERY_TIMEZONE = 'Europe/Moscow' + CELERY_TASK_TRACK_STARTED = True + CELERY_TASK_TIME_LIMIT = 30 * 60 + CELERY_TASK_SOFT_TIME_LIMIT = 20 * 60 CSRF_TRUSTED_ORIGINS = [ 'https://nikdizell.ru', @@ -100,6 +107,7 @@ INSTALLED_APPS = [ 'turnstile', 'products', 'background_task', + 'django_celery_results', ] MIDDLEWARE = [ diff --git a/requirements.txt b/requirements.txt index f9b032f..3d5ee78 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,4 +12,7 @@ django-allauth django-simple-captcha django-turnstile celery -django-background-tasks \ No newline at end of file +django-background-tasks +celery>=5.3.0 +redis>=5.0.0 +django-celery-results>=2.5.0 \ No newline at end of file