Task Queue
Some of the Saleor’s functionality depends on a task queue system to manage asynchronous and periodic tasks. We recommend using Celery with Redis as the message broker. For more information, please visit official Celery documentation.
Periodic tasks
Celery Beat is a scheduler that triggers background tasks at regular intervals. Some of the Saleor's features can't be used without proper task scheduler setup. In order to start Celery Beat server:
- Specify
CELERY_BROKER_URL
environmental variable which points to task broker (we recommend using Redis as a broker database):
set CELERY_BROKER_URL="<broker url>"
An example of the Redis broker url, running on localhost and port 6379, looks like: redis://localhost:6379/0
.
- Run Celery worker:
celery --app saleor.celeryconf:app worker -E --loglevel=info
- As a separate process run Celery Beat:
celery --app saleor.celeryconf:app beat --scheduler saleor.schedulers.schedulers.DatabaseScheduler
Below is a list of Saleor features fired up by celery beat with default schedules:
Tasks run in intervals:
- Deactivate preorder for variants; 1 hour
- Delete empty allocations; 1 hour
- Delete expired reservations; 1 day
- Delete outdated event data; 1 day
- Expire orders; 5 minutes
- Recalculate price for catalog promotions; 30 seconds
- Release funds for abandoned checkouts; 10 minutes
- Remove apps marked as removed; 3 hours
- Update search vectors; 20 seconds
Tasks run at specific time:
- Deactivate expired gift cards; at 0:00 AM
- Delete expired checkouts; at 0:00 AM
- Delete expired orders; at 2:00 AM base on
- Delete old exports files; once per day at 1:00 AM
- Update stocks quantity allocated; once per day at 0:00 AM
- Promotion toggle; based on promotion's start date and end date
important
It is important to understand that without proper task scheduler setup, the actions above will not be triggered.