Saturday, September 24, 2011

Running Django Celery as a Background Process on Webfaction w Virtualenv

I am using Django Celery as a scheduler. I also use virtualenv. I got it to the point were it would work if I ran:

workon my_env
python manage.py celeryd -v 2 -B -s celery -E -l INFO

but when I closed the SSH window, this process stopped. The challenge was to figure out how to keep the process running.

Most of the information I needed was in: http://ask.github.com/celery/cookbook/daemonizing.html#init-script-celerybeat . Thing I was not sure about was what to do about the defaults paths:

/etc/init.d
/etc/default

since I do not think I can put stuff in those paths on webfaction. What I did instead is put a celery dir in my root. In that dir I put the dirs init.d and defult. In ~/celery/init.d I put the script celeryd that I got from https://raw.github.com/ask/celery/master/contrib/generic-init.d/celeryd

If you look at that script, there are lots of things it would seem that should be changed. However most of those changes can be made in the config file. A sample of the config file is at:


chmod 770

Edit ~/celery/init.d/celeryd to change the value of CELERY_DEFAULTS to point to our config file in ~/celery/default/celeryd

I got the values for CELERYD_USER and CELERYD_GROUP by running the command:

id

I created 2 more dirs in ~/celery: logs and run.




No comments:

Post a Comment