Hello How do i configure celery to start automatically when django starts?

asked 17 Feb '11, 14:17

aziz's gravatar image

aziz
117
accept rate: 0%


You Django application is started by a cron job. The easiest way to start djcelery is to add a cron job that starts it.

We have information on using cron here:

http://docs.webfaction.com/software/general.html#scheduling-tasks-with-cron

link

answered 17 Feb '11, 15:26

aaronh's gravatar image

aaronh ♦♦
1.3k3
accept rate: 34%

but wont that cause multiple celery instances to start thus using more memory?

(18 Feb '11, 03:53) aziz aziz's gravatar image

There is documentation here on how to create an init script:

https://github.com/ask/celery/blob/master/contrib/debian/init.d/celeryd

Could you help me map the approp folders to use in webfaction?

(18 Feb '11, 04:01) aziz aziz's gravatar image

You can just use cron and a script to check if celeryd is already running:

#!/bin/bash
SERVICE='celeryd'

if ps -u yourusername -o command | grep -v grep | egrep 'yourapp/myproject/manage.py celeryd' > /dev/null
then
   echo "$SERVICE running, nothing done"
else
   echo "$SERVICE not running, starting..."
   /usr/local/bin/pythonX.Y /home/yourusername/webapps/yourapp/myproject/manage.py celeryd -c 2 &
fi

Save it as celery_daemon.sh and then create an entry in the crontab with something like:

0 1 * * * ~/webapps/yourapp/celery_daemon.sh 2>> ~/webapps/yourapp/sittic_celery.log
link

answered 23 Dec '11, 12:01

Gooler's gravatar image

Gooler
32
accept rate: 0%

note it's important to name your bash script something that won't get picked up in the egrep

You were fine here egrep 'yourapp/myproject/manage.py celeryd' but in my case I had just egrep 'supervisord' and had called my script start_supervisord.sh ...it always thought supervisord was still running!

(17 Mar '13, 15:54) anentropic anentropic's gravatar image

thanks for the handy tip anyway!

(17 Mar '13, 15:54) anentropic anentropic's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×743
×16

Asked: 17 Feb '11, 14:17

Seen: 2,331 times

Last updated: 17 Mar '13, 15:54

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited