diff --git a/backend/communications/tasks.py b/backend/communications/tasks.py index b88fc6e7..9232804e 100644 --- a/backend/communications/tasks.py +++ b/backend/communications/tasks.py @@ -21,7 +21,7 @@ def cleanup_orphaned_attachments(): orphaned = MessageAttachment.objects.filter( message__isnull=True, - created_at__lt=cutoff_time + uploaded_at__lt=cutoff_time ) count = orphaned.count() diff --git a/backend/eusrr_backend/settings.py b/backend/eusrr_backend/settings.py index ad2f71f7..c5d8e0b2 100644 --- a/backend/eusrr_backend/settings.py +++ b/backend/eusrr_backend/settings.py @@ -1,4 +1,5 @@ import os +import tempfile from datetime import timedelta from pathlib import Path @@ -522,6 +523,10 @@ CELERY_TASK_SOFT_TIME_LIMIT = 25 * 60 # Мягкий лимит - 25 минут # Настройки для периодических задач (Celery Beat) CELERY_BEAT_SCHEDULER = 'django_celery_beat.schedulers:DatabaseScheduler' +# PID файлы для Celery (используем /tmp чтобы не требовать root прав) +CELERY_BEAT_PIDFILE = os.path.join(tempfile.gettempdir(), 'celery-beat.pid') +CELERYD_PIDFILE = os.path.join(tempfile.gettempdir(), 'celery-worker.pid') + # Расписание периодических задач CELERY_BEAT_SCHEDULE = { 'cleanup-orphaned-attachments': {