Reputation: 404
Confusion!
Its easy to launch django using supervisor, such as below - based on a tutorial I found:
supervisord.conf:
[program:gunicorn]
command=/home/me/.virtualenvs/app/bin/gunicorn app.wsgi:application --bind 127.0.0.1:8000 ;
Yet celery seems to require its own startup method:
celery -A app worker -l info
So in my ignorance/confusion it appears I have to either start with Gunicorn or Celery. Obviously I'm confused since no doubt many use celery within Supervisor.
Where am I going wrong? How do I use supervisor to start up a celery-django app within Gunicorn?
Upvotes: 2
Views: 2724
Reputation: 66
celery -A app worker -l info
The command above will start an instance of the celery worker in the foreground.
There is an example supervisor configuration available in the celery source if you'd like to use supervisor to daemonize the worker. Supervisor can manage multiple programs, so you can use it to manage gunicorn and one or more instances of celery worker if you'd like.
The celery worker runs as its own process. It connects to a broker (such as redis) and waits for tasks on a queue that you configure. These tasks would be sent from your django app.
The following tutorial does a very good job of explaining how to configure supervisor to launch and manage a celery worker. https://realpython.com/blog/python/asynchronous-tasks-with-django-and-celery/
Upvotes: 5