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).
When you source the
activate
script in a Python virtualenv, what you're basically saying is--set the PATH so that when I typepython
, 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 whatceleryd
binary to use by setting theCELERYD
environment variable. You can set this in/etc/default/celeryd
like so: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.