1

在 localhost 上,我使用这些语句来执行任务和工作人员。运行任务:python manage.py celery beat 运行 worker:python manage.py celery worker --loglevel=info 我使用了 otp、rabbitmq 服务器和 django-celery。它工作正常。我在ubuntu服务器上上传了项目。我想守护这些。为此,我创建了一个文件 /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/sandbox/myprojrepo/myproj"

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

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

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

celery 配置模块的名称。

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="settings"

我还用我下载的脚本创建了一个文件 /etc/init.d/celeryd。

现在,当我尝试执行 /etc/init.d/celeryd start 时,它会给出错误作为无法识别的命令行参数。我发出“celeryd-multi start nodeN”作为命令,它说 nodeN 已启动。但是任务执行还没有开始。

我是守护进程和服务器托管的新手。

4

1 回答 1

2

您可以在主管中运行 celery: https ://pypi.python.org/pypi/supervisor http://thomassileo.com/blog/2012/08/20/how-to-keep-celery-running-with-supervisor/

hth。

于 2013-10-03T08:01:46.740 回答