python - 给 celery 守护进程加花?

标签 python celery flower

是否可以将花添加到 celery 守护进程?

下面是我的 celery 配置文件,我尝试将 flower 配置添加到 CELERYD_OPTS 变量,但失败了。

或者是否有另一个命令我可以添加到配置文件中以使用 celery 启动并运行 flower?

# Names of nodes to start
#   most people will only start one node:
CELERYD_NODES="worker1"
#   but you can also start multiple and configure settings
#   for each in CELERYD_OPTS
#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"

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

# Where to chdir at start.
CELERYD_CHDIR="/itapp/itapp/"

# Extra command-line arguments to the worker
CELERYD_OPTS="flower --ports 5555 --time-limit=300 --concurrency=8"
# Configure node-specific settings by appending node name to arguments:
#CELERYD_OPTS="--time-limit=300 -c 8 -c:worker2 4 -c:worker3 2 -Ofair:worker1"

# Set logging level to DEBUG
#CELERYD_LOG_LEVEL="DEBUG"

# %n will be replaced with the first part of the nodename.
CELERYD_LOG_FILE="/var/log/celery/%n%I.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="celery"
CELERYD_GROUP="celery"

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

最佳答案

我建议使用 supervisordother process control system 运行它们,而不是操作系统初始化脚本和启动停止守护进程。

worker 和 flower 都应该作为守护进程并排运行,有 many docs on how to run celery worker with supervisord , run flower 只是简单地增加了一个程序段,将 worker 命令替换为相应的 flower 启动命令,如 celery flower -A itapp --ports 5555 --time-limit=300 --concurrency=8.

关于python - 给 celery 守护进程加花?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46348992/

相关文章:

python - 购买内存以避免 30-50Gb 以上的文件分块

python - celery 执行期间出现 Airflow 错误

docker - 不以 root 身份运行时从容器访问命名卷?

docker - 如何使用花来监控1个以上的 worker

python - 装饰器抑制 'unfilled parameter' 警告

python - 如何子类化 Pandas DataFrame?

python - 动态添加/删除线程到 celery 中的工作池

php - 如何获取 Celery 中失败的任务?

Windows 中的 Python 时间格式不同

Django celery 4 - ValueError : invalid literal for int() with base 10 when start celery worker