This project uses Celery for background task processing and django-celery-beat for periodic task scheduling. Below are the steps and commands to get everything running for local development.
If Redis is not already installed on your system:
sudo apt update
sudo apt install redis-server -y
Since systemd
may not be available (e.g., in a Codespace), start Redis manually:
redis-server &
redis-cli ping
# Expected output: PONG
If
redis-cli
is missing:
sudo apt install redis-tools
This runs your web application on localhost
.
python3 manage.py runserver
This command starts the Django application at http://127.0.0.1:8000/.
Use it to access the Django admin panel and trigger/view task results.
This runs the Celery worker, which listens for tasks and executes them in the background.
celery -A myproject worker --loglevel=info
-A myproject
refers to the project directory containingcelery.py
.--loglevel=info
shows task processing logs in the terminal.
✅ Make sure Redis is running before starting the worker.
This runs the beat service, which schedules and dispatches periodic tasks.
celery -A myproject beat --loglevel=info
- This should run in a separate terminal.
- Beat uses the database schedule from the
django-celery-beat
app.
You can define and manage periodic tasks directly from the Django admin under "Periodic Tasks".
Service | Command | Description |
---|---|---|
Redis Server | redis-server & |
Starts Redis manually in foreground |
Django Server | python3 manage.py runserver |
Web server and admin access |
Celery Worker | celery -A myproject worker --loglevel=info |
Executes background tasks |
Celery Beat | celery -A myproject beat --loglevel=info |
Schedules and dispatches periodic tasks |