【问题标题】:How to create Daemon for celery?如何为芹菜创建守护进程?
【发布时间】:2016-03-10 11:51:29
【问题描述】:

我尝试为 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"

# Where to chdir at start.
CELERYD_CHDIR="/home/ubuntu/workspace/ward/www“
ENV_PYTHON=“/usr/bin/python3”

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

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

# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=2 --beat --events --loglevel=info"

# Name of the celery config module.
CELERY_CONFIG_MODULE="celeryconfig"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/var/logs/celery/%n.log"
CELERYD_PID_FILE="/var/run/celery/%n.pid"

# Workers should run as an unprivileged user.
CELERYD_USER=“ubuntu”
CELERYD_GROUP=“ubuntu”

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE=“fb_archive.settings"

它没有任何错误。 但是我的 django 项目不能使用 celery。

如果我运行这段代码,celery --app=fb_archive.celery:app worker -B --loglevel=INFO,django 项目可以使用 celery。

【问题讨论】:

标签: python django celery


【解决方案1】:
# Names of nodes to start
#   most people will only start one node:
CELERYD_NODES="worker"
#   but you can also start multiple and configure settings
#   for each in CELERYD_OPTS (see `celery multi --help` for examples):
#CELERYD_NODES="worker1 worker2 worker3"
#   alternatively, you can specify the number of nodes to start:
#CELERYD_NODES=10

# Absolute or relative path to the 'celery' command:
CELERY_BIN="/usr/local/bin/celery"
#CELERY_BIN="/virtualenvs/def/bin/celery"

# App instance to use
# comment out this line if you don't use an app
CELERY_APP="fb_archive.celery:app"
# or fully qualified:
#CELERY_APP="proj.tasks:app"

# Where to chdir at start.
CELERYD_CHDIR="/home/ubuntu/workspace/ward/www"

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

# %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.
#   You need to create this user manually (or you can choose
#   a user/group combination that already exists, e.g. nobody).
CELERYD_USER="root"
CELERYD_GROUP="root"

# If enabled pid and log directories will be created if missing,
# and owned by the userid/group configured.
CELERY_CREATE_DIRS=1

成功了!

【讨论】:

  • 请帮助遇到类似情况的其他人,说明问题出在哪里、解决了什么问题以及原因
猜你喜欢
  • 1970-01-01
  • 2011-09-26
  • 1970-01-01
  • 1970-01-01
  • 2019-12-07
  • 1970-01-01
  • 2017-12-14
  • 2014-11-11
  • 1970-01-01
相关资源
最近更新 更多