我正在尝试为在 virtualenv 中运行的 django 守护进程。我将 celeryd 文件从https://github.com/celery/celery/tree/master/extra/generic-init.d复制 到 /etc/init.d/
然后我创建了一个配置文件,其内容位于http://ask.github.io/celery/cookbook/daemonizing.html#example-django-configuration-using-virtualenv并将其保存为 /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 --fake --time-limit=300 --concurrency=8 /etc/init.d /celeryd: 140: /etc/init.d/celeryd: celeryd-multi: 未找到
我可以看到它无法找到 celeryd_multi。奇怪的是,跑步
/path/to/project_env/bin/python /path/to/manage.py celeryd_multi
显示 celeryd-multi 可用。
[更新 - 用@Daniel Roseman 的输入更正我的启动命令]
现在,当我运行时:
sh -x /etc/init.d/celeryd start
这是我看到的输出:
/path/to/.virtualenvs/virtenv/bin/python /path/to/project//manage.py celeryd_detach --time-limit=300 --concurrency=8 --gid=celery --broker=amqp:// :@localhost:5672// -n w1.ubuntu-12-10 --logfile=/var/log/celery/w1.log --loglevel=INFO --uid=celery --pidfile=/var/run/celery /w1.pid --workdir=/path/to/project/
好的
+ 睡眠 5
+ 退出 0
我在这里想念什么?请帮忙!