无法在服务器上将 Celery 设置为守护进程
Cannot setup Celery as daemon on server
我无法在服务器上将 Celery 设置为守护进程(django 1.6.11、celery 3.1、Ubuntu 14.04)
尝试了很多选项,任何人都可以将完整的工作配置设置为 运行 celery 作为守护进程吗?
我对官方文档 http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts - none 非常失望,没有完整的分步教程。 youtube 上有零 (!!!) 个关于如何设置守护进程的视频。
现在我可以通过 celery worker -A engine -l info -E 来 运行 celery simple
来自 django 的任务已成功执行。
我已经完成配置:
/etc/defaults/celery
# 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
所以,没有错误!任务没有被调用,我不知道出了什么问题。
我建议使用 Supervisor. It's better way than init scripts, because you can run multiple Celery instances for different projects on one server. Example config for Supervisor you can find in Celery repo 或我项目中的完整示例:
# /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
我无法在服务器上将 Celery 设置为守护进程(django 1.6.11、celery 3.1、Ubuntu 14.04) 尝试了很多选项,任何人都可以将完整的工作配置设置为 运行 celery 作为守护进程吗?
我对官方文档 http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts - none 非常失望,没有完整的分步教程。 youtube 上有零 (!!!) 个关于如何设置守护进程的视频。
现在我可以通过 celery worker -A engine -l info -E 来 运行 celery simple 来自 django 的任务已成功执行。
我已经完成配置:
/etc/defaults/celery
# 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
所以,没有错误!任务没有被调用,我不知道出了什么问题。
我建议使用 Supervisor. It's better way than init scripts, because you can run multiple Celery instances for different projects on one server. Example config for Supervisor you can find in Celery repo 或我项目中的完整示例:
# /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