I decided I need to use an asynchronous queue system. And am setting up Redis/RQ/django-rq. I am wondering how I can start workers in my project.

django-rq provides a management command which is great, it looks like:

python manage.py rqworker high default low

But is it possible to start the worker when you start the django instance? Just wondering or is it something I will always have to start manually?

Thanks.

有帮助吗?

解决方案

Django operates inside reques-response cycle, and it starts by request. So it is bad idea to attach such command to Django startup.
Instead of that, I would recommend you to look at supervisord - a process manager, that can automate services launch at system start and other things.

其他提示

When I host Django project in Heroku. Heroku provide a Procfile, you can specify what to start with project. It is my Procfile:

web: gunicorn RestApi.wsgi
worker: python manage.py rqworker default
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top