如何在 ubuntu 服务器上守护 django celery 周期任务



在本地主机上,我使用这些语句来执行任务和工作线程。运行任务:蟒蛇 manage.py 芹菜节拍运行辅助角色: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_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启动了。但是任务执行尚未开始。

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

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

呵。

最新更新