Skip to content

Phase 1: Celery Infrastructure Setup #1828

@ad-m-ss

Description

@ad-m-ss

Phase 1: Celery Infrastructure Setup

Overview

Set up the complete Celery infrastructure with RabbitMQ backend to replace the current cron-based background job system. This provides the foundation for migrating all existing management commands to robust, scalable background tasks.

Scope

This issue covers the basic Celery infrastructure setup without any task migration. Task migration will be handled in subsequent issues.

Tasks

1.1 Docker Services Configuration

  • Add RabbitMQ service to docker-compose.yml
  • Add Celery worker service for background task processing
  • Add Celery beat service for periodic task scheduling
  • Configure proper networking and environment variables

1.2 Dependencies

  • Add Celery dependencies to requirements/base.txt:
    • celery[rabbimtq]>=5.3.0
    • django-celery-beat>=2.5.0 (database-backed periodic tasks)
    • django-celery-results>=2.5.0 (task result storage)

1.3 Django Configuration

  • Create poradnia/celery.py with Celery app configuration
  • Update poradnia/__init__.py to import Celery app
  • Configure Django settings for Celery broker, backend, and task routing
  • Set up task autodiscovery for all Django apps
  • Add Celery-related settings to development and production configurations

Files to Modify

Docker Configuration

  • docker-compose.yml - Add RabbitMQ, Celery worker, and Celery beat services
  • .contrib/docker/ - Update Docker-related scripts if necessary

Requirements

  • requirements/base.txt - Add Celery and RabbitMQ dependencies

Django Configuration

  • poradnia/celery.py - NEW FILE - Main Celery configuration
  • poradnia/__init__.py - Import Celery app
  • poradnia/settings/base.py - Celery broker/backend configuration
  • poradnia/settings/dev.py - Development-specific Celery settings
  • poradnia/settings/production.py - Production Celery configuration

Acceptance Criteria

  • RabbitMQ service runs successfully in Docker environment
  • Celery worker service starts without errors
  • Celery beat service starts without errors
  • Django can successfully connect to RabbitMQ broker
  • Celery can autodiscover tasks from Django apps
  • All services integrate properly with existing development workflow
  • make start command works with new services
  • New Celery-specific make commands are available

Development Commands to Add

make celery-worker          # Start Celery worker
make celery-beat           # Start Celery beat scheduler  
make celery-status         # Check worker status

Dependencies

This issue has no dependencies and can be worked on immediately.

Related Issues

This issue enables the following task migration work:

All Phase 2 task migration issues depend on the completion of this infrastructure setup.

Testing

  • Verify all Docker services start successfully
  • Test RabbitMQ connectivity from Django
  • Verify Celery worker can receive and process test tasks
  • Confirm Celery beat can schedule test periodic tasks

Current System Context

The project currently uses cron-based background jobs managed in .contrib/docker/cron/. This infrastructure setup maintains the existing system while adding Celery capability. The cron system will be phased out in subsequent task migration issues.

References

  • Current cron configuration: .contrib/docker/cron/set_crontab.sh
  • Existing management commands to be migrated later:
    • poradnia/judgements/management/commands/run_court_session_parser.py
    • poradnia/events/management/commands/send_event_reminders.py
    • poradnia/cases/management/commands/send_old_cases_reminder.py

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions