-
Notifications
You must be signed in to change notification settings - Fork 13
Description
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.0django-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.pywith Celery app configuration - Update
poradnia/__init__.pyto 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 configurationporadnia/__init__.py- Import Celery appporadnia/settings/base.py- Celery broker/backend configurationporadnia/settings/dev.py- Development-specific Celery settingsporadnia/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 startcommand 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 statusDependencies
This issue has no dependencies and can be worked on immediately.
Related Issues
This issue enables the following task migration work:
- Blocks: Phase 2: Background Task Migration to Celery (Umbrella Issue) #1829 - Phase 2: Background Task Migration to Celery (Umbrella Issue)
- Blocks: Migrate run_court_session_parser to Celery Task #1830 - Migrate run_court_session_parser to Celery Task
- Blocks: Migrate send_event_reminders to Celery Task #1831 - Migrate send_event_reminders to Celery Task
- Blocks: Migrate send_old_cases_reminder to Celery Task #1832 - Migrate send_old_cases_reminder to Celery Task
- Blocks: Migrate Django clearsessions to Celery Task #1833 - Migrate Django clearsessions to Celery Task
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.pyporadnia/events/management/commands/send_event_reminders.pyporadnia/cases/management/commands/send_old_cases_reminder.py