Search code examples
djangorediscelery

Celery + Redis + Django task not running


I have a django website and recently based on this tutorial have installed celery, redis and configured files. HAve deployed the project on digitalocean server. Now issue I am facing is that whenever .delay() is called, task is not getting executed. But when I use below command in project folder, task is discovered and executed.

python -m celery -A django_celery worker -l info

What should I do so that every time a user calls function, celery automatically discoveres task and execute it?


Solution

  • Celery is a distributed task queue. You should start a worker process which listens on the Redis broker, fetches and executes them as they come. Django API runs in a separate process and pushes messages to the broker.

    For running worker in the background without exiting, you can either use docker or use supervisor. For testing purposes, you can use nohup and run the process in the background or terminal multiplexer.