Django 未找到芹菜进程芹菜多进程守护进程

Django 未找到芹菜进程芹菜多进程守护进程,django,deployment,celery,django-celery,init.d,Django,Deployment,Celery,Django Celery,Init.d,我正在尝试将django在virtualenv中运行的芹菜进程daemonize。我将celeryd文件从复制到/etc/init.d/ 然后,我创建了一个配置文件,其内容位于,并将其保存为/etc/default/celeryd 这是我的/etc/default/celeryd: # Name of nodes to start, here we have a single node CELERYD_NODES="w1" # or we could have three nodes: #CEL

我正在尝试将django在virtualenv中运行的芹菜进程daemonize。我将celeryd文件从复制到/etc/init.d/

然后,我创建了一个配置文件,其内容位于,并将其保存为/etc/default/celeryd

这是我的/etc/default/celeryd:

# Name of nodes to start, here we have a single node
CELERYD_NODES="w1"
# or we could have three nodes:
#CELERYD_NODES="w1 w2 w3"

# Where to chdir at start.
CELERYD_CHDIR="/home/manu/location/to/project/"

# Python interpreter from environment.
ENV_PYTHON="/home/manu/.virtualenvs/project_env/bin/python"

# How to call "manage.py celeryd_multi"
CELERYD_MULTI= "$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryd_multi"

# How to call "manage.py celeryctl"
CELERYCTL="$ENV_PYTHON $CELERYD_CHDIR/manage.py celeryctl"

# Extra arguments to celeryd
CELERYD_OPTS="--verbose --fake --time-limit=300 --concurrency=8"

# Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user.
CELERYD_USER="celery"
CELERYD_GROUP="celery"

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="project.settings.production"
当我跑步时:

sudo sh -x /etc/init.d/celeryd start
它失败,出现以下错误:

celeryd multi-start w1--uid=celery--gid=celery--workdir=/home/manu/location/to/project/--pidfile=/var/run/celery/%n.pid--logfile=/var/log/celery/%n.log--loglevel=INFO--cmd m celery.bin.celeryd detach--verbose--false--time limit 300--concurrency=8/etc init.d/celeryd 140:/etc init.d/celeryd:celeryd multi:未找到

我可以看出它找不到芹菜。奇怪的是,跑

/path/to/project\u env/bin/python/path/to/manage.py celeryd\u multi

显示celeryd multi可用

[更新-使用@Daniel Roseman的输入更正我的启动命令]

现在,当我跑步时:

sudo sh -x /etc/init.d/celeryd start
sh-x/etc/init.d/celeryd start

这是我看到的输出:

/path/to/.virtualenvs/virtenv/bin/python/path/to/project//manage.py celeryd_detach——时间限制=300——并发性=8——gid=celery --broker=amqp://:@localhost:5672// -n w1.ubuntu-12-10--logfile=/var/log/芹菜/w1.log--loglevel=INFO--uid=芹菜--pidfile=/var/run/芹菜/w1.pid--workdir=/path/to/project/

+睡眠5

+出口0


我错过了什么?请帮忙

当您使用
sudo sh
执行命令时,您正在启动一个全新的shell环境。在该环境中,您的virtualenv未被激活,virtualenv的
bin
目录将不在路径上,这大概就是找不到可执行文件的原因


如果您确实需要以超级用户的身份运行它,那么应该创建一个包装器脚本,在
sudo
调用中执行virtualenv。

您的init.d脚本引用的是系统python包,而不是virtualenv python。因此,当您在其中运行芹菜时,您引用的是安装在系统站点包中的芹菜

在调用芹菜之前添加对virtualenv-python路径的引用,一切都会正常工作


也就是说,通常最好使用init.d运行supervisord,然后让supervisord启动所有其他进程,如芹菜和web应用程序。

非常感谢您的输入!我自己也不会明白的。正如@Daniel Roseman所说,我试图在命令前不使用sudo。现在它似乎正在启动一些节点,但是在
ps aux|grep芹菜中我没有看到芹菜进程