gpt4 book ai didi

python - Celery 连接到远程服务器broker_url

转载 作者:太空宇宙 更新时间:2023-11-03 16:12:09 24 4
gpt4 key购买 nike

我正在按照docs守护 celery 。

我的 BROKER_URL 已按以下格式设置:- 'amqp://<user>:<password>@<ip>/<vhost>' .

所以,当我手动启动 celery 时,celery worker -A app_name ,它与远程服务器连接。但是当我守护它时,它会与本地主机 amqp 连接。有什么原因吗?

这是我创建 celery 对象的方法:-

app = Celery('c26_search')    
app.config_from_object('django.conf:settings')
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.update(
CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend'
)
print app.conf.BROKER_URL # prints remote url

我的settings.py文件:-

CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
BROKER_URL = `'amqp://<user>:<password>@<ip>/<vhost>'`

为什么表现得这么奇怪?即使它打印了远程 IP url,但仍然尝试连接本地 amqp?

最佳答案

嗯,我找到了问题的答案:-

通行证经纪人网址为 CELERY_OPTSCELERYD_OPTS="-n worker2.%h --broker=amqp://<user>:<password>@<ip>/<vhost>"在 celeryd 文件中。

关于python - Celery 连接到远程服务器broker_url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39184400/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com