首页 文章

无法在服务器上将Celery设置为守护程序

提问于
浏览
0

我无法在服务器上设置Celery作为守护进程(django 1.6.11,芹菜3.1,Ubuntu 14.04)尝试了很多选项,任何人都可以完全设置工作配置来运行celery作为守护进程吗?

我对官方文档非常失望http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts - 没有这个工作,没有完整的分步教程 . youtube上有关如何设置守护程序的零(!!!)视频 .

现在我能够通过芹菜 Worker 简单地运行芹菜 - 来自django的引擎-l info -E任务成功执行 .

我做过配置:

的/ etc /默认/芹菜

# 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"

# Absolute path to "manage.py"
CELERY_BIN="/var/www/engine/manage.py"

# How to call manage.py
CELERYD_MULTI="celery multi"

# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=2"

# %N will be replaced with the first part of 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="root"
CELERYD_GROUP="root"

/etc/init.d/celeryd
来自https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd没有变化

现在,当我去控制台并运行时:cd /etc/init.d芹菜多启动w1

我看到输出:

celery multi v3.1.11 (Cipater)
> Starting nodes...
        > w1@engine: OK

所以,没有错误!任务没有被调用,我无法弄清楚什么是错的 .

1 回答

  • 2

    我建议使用Supervisor . 它比init脚本更好,因为您可以在一台服务器上为不同的项目运行多个Celery实例 . 您可以在我的项目的Celery repo或完整工作示例中找到Supervisor的示例配置:

    # /etc/supervisor/conf.d/celery.conf
    [program:celery]
    command=/home/newspos/.virtualenvs/newspos/bin/celery worker -A newspos --loglevel=INFO
    user=newspos
    environment=DJANGO_SETTINGS_MODULE="newspos.settings"
    directory=/home/newspos/projects/newspos/
    autostart=true
    autorestart=true
    stopwaitsecs = 600
    killasgroup=true
    startsecs=10
    stdout_logfile=/var/log/celery/newspos-celeryd.log
    stderr_logfile=/var/log/celery/newspos-celeryd.log
    

相关问题