0

I am attempting to daemonize a paster process which launches celeryd.

celeryd is a paster script that only exists within the python virtual environment.

I have no problem with paster serve, as that can daemonize itself. celeryd does not have this ability coded (as the developer has not included it) and it is recommended to use an init script that had been contributed to the project. However, I am unsure how to integrate the need for the virtual environment and paster into this script.

How do I have a paster celeryd process daemonize itself?

Thanks.

[update] I eventually simply opted to drop the process to the background using &. I'm working out the command syntax for handling this in an init script. You must send a SIGINT signal (try kill -SIGINT $(cat /var/run/celeryd.pid)) to the paste process for it to perform the warm shutdown (properly shutting down the celeryd instance that is spawned by marcin's paste script celeryd (yes, it's a bit confusing).

  • kinda seems strange deamonize a paster... I know its not demon but hay .. – tony roth Oct 25 '11 at 16:03
  • I don't understand the relevance of your comment. – mbrownnyc Oct 25 '11 at 16:50
2

When you source the activate script in a Python virtualenv, what you're basically saying is--set the PATH so that when I type python, it refers to the executable in the virtualenv. The other actions it takes are largely cosmetic, or exist for the purposes of being able to "deactivate" the virtual environment.

With that in mind, then when you install celery into your virtual environment, setuptools will set the path for all your scripts to look, specifically, at your virtual environment's python binary. Now, enter the celeryd init script. You can override what celeryd binary to use by setting the CELERYD environment variable. You can set this in /etc/default/celeryd like so:

CELERYD=/path/to/virtualenv/bin/celeryd

That should launch the celeryd binary using your virtual environment. Hope this helps, and let me know if you run into any hiccups!

NOTE: This will be true for any Python script--provided the #! header at the top of the script points to your Python executable of choice, you can use your virtualenv.

  • I'll try this out later then accept the answer accordingly. Great info, and it looks like it will work! Thanks so much. You guessed correctly that I am new to virtualenvs. – mbrownnyc Oct 25 '11 at 18:55
  • No problem! There's a lot of magic that goes on behind the scenes--which is great when you just want it to work. I just happen to know a little more because of problems like the one you're running in to! – Andrew M. Oct 25 '11 at 19:22
  • It appears that, since I am using a paster script, it is not as simple as prepending the PATH to the paster bin, since I need to pull the celeryd config out of a paste config file. It has been reported by the dev of the project who builds the paste config, that changes in the future might cause issues launching celeryd leveraging an external config. I suppose with every upgrade of the project (rhodecode), I can then manually write the celeryd config from the produced paste conf file. Thanks anyway. I don't think this question can be answered any other way, so here's some points! – mbrownnyc Oct 25 '11 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.