没有-A选项的情况下如何运行芹菜状态/花朵? [英] How do I run celery status/flower without the -A option?

查看:103
本文介绍了没有-A选项的情况下如何运行芹菜状态/花朵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑此bash会话:

$ export DJANGO_SETTINGS_MODULE=web.settings
$ celery status -b redis://redis.businessoptics.dev:6379/1 -t 10
Error: No nodes replied within time constraint.
$ celery status -b redis://redis.businessoptics.dev:6379/1 -t 10 -A scaffold.tasks.celery_app
celery@worker.9e2c39a1c42c: OK

为什么需要 -A 选项?据我所知,芹菜应该能够在Redis上检测到必要的元数据.

Why do I need the -A option? As far as I can tell celery should be able to detect the necessary metadata on redis.

类似地,如果我运行 celery flower -b< redis url> ,它表明它已成功连接到Redis,但未显示任何实际的工作程序/任务/队列,并且显示了诸如>统计信息"的检查方法失败.同样,添加 -A 使其起作用.

Similarly if I run celery flower -b <redis url> it shows that it successfully connects to redis but doesn't show any real workers/tasks/queues and shows several messages like 'stats' inspect method failed. Again, adding -A causes it to work.

我想在不包含任何我的代码或其依赖项的最小型独立Docker容器中运行flower.诸如这个之类的几个存储库都提供了这种功能.那我该怎么办呢?链接的存储库提供了许多选项,但是没有办法指定 -A 选项,这表明没有必要.

I want to run flower in a minimal standalone Docker container that doesn't contain any of my code or its dependencies. Several repos such as this one offer this kind of thing. So how can I do that? The linked repo offers many options but no way to specify the -A option, which suggests it is not necessary.

我是芹菜的初学者,所以我可能会缺少一些愚蠢的东西.我该怎么办?

I'm a beginner to celery so I may be missing something stupid. What am I supposed to do?

scaffold.tasks.celery_app 模块看起来像这样:

from celery import Celery
from django.conf import settings

app = Celery()
app.config_from_object(settings)

以下是涉及芹菜的Django设置:

And these are the Django settings that involve celery:

{'BROKER_HEARTBEAT': 0,
 'BROKER_TRANSPORT_OPTIONS': {'fanout_patterns': True,
                              'fanout_prefix': True,
                              'visibility_timeout': 172800},
 'BROKER_URL': 'redis://redis.businessoptics.dev:6379/1',
 'CELERYBEAT_SCHEDULE': {'journey-heartbeat': {'args': (),
                                               'schedule': <crontab: * * * * * (m/h/d/dM/MY)>,
                                               'task': 'kms.data.journey.tasks.heartbeat'}},
 'CELERYD_CONCURRENCY': 1,
 'CELERYD_HIJACK_ROOT_LOGGER': False,
 'CELERYD_LOG_COLOR': False,
 'CELERYD_MAX_TASKS_PER_CHILD': 1,
 'CELERYD_PREFETCH_MULTIPLIER': 1,
 'CELERY_ACCEPT_CONTENT': ['pickle'],
 'CELERY_ACKS_LATE': True,
 'CELERY_DEFAULT_EXCHANGE': 'default',
 'CELERY_DEFAULT_EXCHANGE_TYPE': 'direct',
 'CELERY_DEFAULT_QUEUE': 'default',
 'CELERY_DEFAULT_ROUTING_KEY': 'default',
 'CELERY_IGNORE_RESULT': False,
 'CELERY_IMPORTS': ['kms.knowledge.query.tasks2',
                    # names of several more modules...
                   ],
 'CELERY_QUEUES': [<unbound Queue tablestore -> <unbound Exchange default(direct)> -> kms.data.table_store.tasks.#>,
                    # several more similar-looking Queues...
                   <unbound Queue default -> <unbound Exchange default(direct)> -> default>],
 'CELERY_REDIRECT_STDOUTS': False,
 'CELERY_RESULT_BACKEND': 'database',
 'CELERY_RESULT_DBURI': 'mysql://businessoptics:businessoptics@mysql.businessoptics.dev:3306/product',
 'CELERY_RESULT_DB_SHORT_LIVED_SESSIONS': True,
 'CELERY_ROUTES': ['scaffold.tasks.routers.TaskNameRouter'],
 'CELERY_SEND_EVENTS': True,
 'CELERY_SEND_TASK_ERROR_EMAILS': False,
 'CELERY_SEND_TASK_SENT_EVENT': True,
 'CELERY_STORE_ERRORS_EVEN_IF_IGNORED': True,
 'CELERY_TASKNAME_ROUTES': [('tablestore', 'kms.data.table_store.tasks.#'),
                            # bunch of routes...
                            ],
 'CELERY_TASK_RESULT_EXPIRES': None,
 'CELERY_TIMEZONE': 'UTC',
 'CELERY_TRACK_STARTED': True,
 'CELERY_WORKER_DIRECT': True
}

以下是相关版本:

celery==3.1.19
Django==1.8
django-celery==3.1.0
redis==2.10.3

推荐答案

-A选项是传递带有相关配置(包括包含您的任务的软件包)的celery实例的选项.

The -A option is the one that passes the celery instance with related configuration including the package containing your tasks.

要使用花朵的所有功能,必须像工作人员一样配置花朵,这意味着知道您的芹菜任务所在的包装并知道它们.

To use all the features flowers needs to be configured like a worker, this means knowing the package where your celery tasks are and knowing them.

将所需的python库添加到您的docker容器中应该不会那么难,例如您可以将其添加到

Add to your docker container the needed python lib shouldn't be that hard, for example you could add to this file the configuration line CELERY_IMPORTS in the following way:

CELERY_IMPORTS  = os.getenv('CELERY_IMPORTS  ', 'default.package') 

更新

芹菜创造者@asksol在评论中指出,这是为什么需要-A选项的更详细说明:

As @asksol, celery creator, pointed out in the comments here's a more detailed explanation of why you need the -A option:

花也是消息的使用者,因此将有助于恢复未确认的消息.由于定义了自定义可见性,因此未配置启动花意味着它将使用默认的可见性超时,因此比工作人员更快地重新发送未确认的消息.始终使用-A,以便使工作人员,鲜花和客户端配置保持同步

Flower is also a message consumer and so will help recover unacked messages. Since you have a custom visibility defined, starting flower unconfigured means it will use the default visibility timeout and thus will redeliver unacked messages faster than your workers. Always use -A so that worker, flower and client configuration is in sync

这篇关于没有-A选项的情况下如何运行芹菜状态/花朵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆