2

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.

Ryan Currah
  • 1,067
  • 6
  • 15
  • 30

2 Answers2

1

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.

Gill Bates
  • 14,330
  • 23
  • 70
  • 138
  • I accidentally deleted my old comment. I wanted to provide something a little more useful than thank you. One of the main reasons I chose rq was that it is easy to setup and it supported scheduling tasks(rq-scheduler) The issue i ran into was the scheduling system you could only give it a start time and interval. I need cron type scheduling. I switched to celery although i was scared of the time to setup/learn. Turns out the documentation is pretty good made it not bad. I took your advice and stopped trying to start with django and used the init.d scripts celery provides. – Ryan Currah Apr 05 '14 at 00:10
0

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
anhlt
  • 384
  • 1
  • 4
  • 11