检查芹菜工人的状态 [英] Check status of Celery worker
问题描述
我有一个使用Celery的项目.我经常遇到一种情况,我的请求正在向Celery发出,但任务没有移交给工作人员,而是服务器仅返回500错误.
I have a project that uses Celery. I am periodically running into a scenario where my requests are making it to Celery but the tasks aren't being handed off to the workers, but rather the server is just returning a 500 error.
当我重新启动Celery时,它将再次开始工作.我只是在猜测工人正在吊死,这使得它不再可用.如果我启动另一批工作者,则请求将再次开始工作(这支持我的理论).
When I restart Celery it starts working again. I am only guessing that the worker is hanging which makes it so there aren't anymore workers available. If I startup another batch of workers the requests start working again (which supports my theory).
问题:
- 我了解芹菜默认情况下会记录到stderr.我没有看到任何错误,所以我希望某个地方还有另一个芹菜日志.那会在哪里?
- 有什么方法可以查询工人的状况吗?有空吗?他们挂了吗?
- 还有其他吗?
推荐答案
您可以使用Flower API或通过以下方式直接查询芹菜来查看活跃的工作人员:
you can see active workers using flower API or by directly querying celery using below manner:
from celery import Celery
celery = Celery('vwadaptor',
broker='redis://workerdb:6379/0',backend='redis://workerdb:6379/0')
celery.control.inspect().active()
向您显示活动工作人员及其当前执行的工作.
Shows you the active workers and their currently executing jobs.
这篇关于检查芹菜工人的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!