Celery
Celery is a tool we use to run tasks in the background. It’s really helpful when you need to do things asynchronously, like sending emails or generating reports.
We’ve already set up Celery for you in Django Easystart, so you don’t need to worry about configuring it yourself. It comes with a worker and a beat worker, so you can start using it right away.
If you’re using Docker in development, then Celery should be already configured and running for you. That means you can start creating background tasks and see them get processed automatically.
Celery Worker
A worker in Celery is a process that is responsible for executing tasks. It listens to the task queue and picks up tasks as they become available, then executes them in the background.
Celery Beat
A beat worker, also known as a Celery beat, is a scheduler that is used to execute tasks at specific times or intervals. It is responsible for sending tasks to the worker processes based on the specified schedule.
Celery Worker
The command used to run the Celery Worker is the following:
celery -A {{ project_name }} worker -l info
To view the logs for the Celery Worker, run the following command:
docker compose logs celery_worker -f
Celery Beat
The command used to run the Celery Beat is the following:
celery -A {{ project_name }} beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler
To view the logs for the Celery Beat, run the following command:
docker compose logs celery_beat -f