nana1243 / celery-example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django and Celery and Redis

1. You need to install Celery and Redis in

your virtual environments

pip install celery
pip install redis

2. Redis is broker server

  • check your settings.py
CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TIMEZONE = TIME_ZONE
CELERY_IMPORTS = "calculation.task"

3. Run your broker server

in your terminal

redis-server

Screen Shot 2021-05-09 at 1 19 57 PM

4. Next run your Django server

python manage.py runserver

5. Next Step Run your Celery worker

celery -A project_name worker -l info

example:

celery -A celearyapp worker -l info

then ,

Screen Shot 2021-05-09 at 1 25 04 PM

Screen Shot 2021-05-09 at 1 22 37 PM

6. Next run your Scheduler

celery -A project_name worker -l info

example:

celery -A celearyapp worker -l info

Screen Shot 2021-05-09 at 1 28 22 PM

About


Languages

Language:Python 100.0%