gpt4 book ai didi

redis - Flower Broker选项卡中不支持“带有SSL的Redis”代理

转载 作者:行者123 更新时间:2023-12-03 06:38:49 26 4
gpt4 key购买 nike

我们正在使用Flower以Redis作为我们项目的经纪人监视Celery的任务。

当我们使用SSL将Redis配置为代理时,在代理选项卡中,我们可以看到下一条消息:

'redis' broker is not supported



我们试图(并成功)通过下一个URL从Celery连接到Redis:
rediss://{REDIS_HOST}:{REDIS_PORT}/{REDIS_DB_NAME}?{SSL_OPTIONS}

如Celery文档中所示。

此外,我们尝试了 --broker--broker_api参数,结果相同。

工作程序和任务运行正常(在工作程序内部,代理正常显示),但是“代理”选项卡为空。

如果我们查看Celery代码,则可以发现Celery如何管理URL解析以设置Redis作为代理的ssl选项和配置:

        if scheme == 'redis':
# If connparams or query string contain ssl params, raise error
if (any(key in connparams for key in ssl_param_keys) or
any(key in query for key in ssl_param_keys)):
raise ValueError(E_REDIS_SSL_PARAMS_AND_SCHEME_MISMATCH)

if scheme == 'rediss':
connparams['connection_class'] = redis.SSLConnection
# The following parameters, if present in the URL, are encoded. We
# must add the decoded values to connparams.
for ssl_setting in ssl_param_keys:
ssl_val = query.pop(ssl_setting, None)
if ssl_val:
connparams[ssl_setting] = unquote(ssl_val)

如果我们查看Flower代码,就会发现Flower如何管理网址解析以设置代理:

        class Broker(object):
def __new__(cls, broker_url, *args, **kwargs):
scheme = urlparse(broker_url).scheme
if scheme == 'amqp':
return RabbitMQ(broker_url, *args, **kwargs)
elif scheme == 'redis':
return Redis(broker_url, *args, **kwargs)
elif scheme == 'redis+socket':
return RedisSocket(broker_url, *args, **kwargs)
else:
raise NotImplementedError

如我们所见,Flower似乎不支持带SSL的Redis(仅支持redis,不支持rediss)。

这是真的?有什么方法可以在 celery 和鲜花中使用Rediss与Redis连接,或者在没有Rediss的情况下使用SSL与Redis连接?

谢谢!

最佳答案

它与以下URL选项一起使用。
证书的百分比编码路径或普通路径均适用。
rediss和redis计划均有效。
使用 celery == 4.4.7,花= = 0.9.5

export SSL_CACERT_PATH="%2Fvar%2Fssl%2Fmyca.pem"
export SSL_CLIENT_CERT_PATH="%2Fvar%2Fssl%2Fclient-cert.pem"
export SSL_CLIENT_KEY_PATH="%2Fvar%2Fssl%2Fprivate%2Fworker-key.pem"
OR
export SSL_CACERT_PATH=/var/ssl/myca.pem
export SSL_CLIENT_CERT_PATH=/var/ssl/client-cert.pem
export SSL_CLIENT_KEY_PATH=/var/ssl/private/worker-key.pem

#Ensure no whitespaces if breaking lines
export REDISS_BROKER_URL="rediss://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}?\
ssl_cert_reqs=required\
&ssl_ca_certs=${SSL_CACERT_PATH}\
&ssl_certfile=${SSL_CLIENT_CERT_PATH}\
&ssl_keyfile=${SSL_CLIENT_KEY_PATH}"

flower -b $REDISS_BROKER_URL

#Ensure no whitespaces if breaking lines
export REDIS_BROKER_URL="redis://:${REDIS_PASSWORD}@${REDIS_HOST}:${REDIS_PORT}?\
ssl_cert_reqs=required\
&ssl_ca_certs=${SSL_CACERT_PATH}\
&ssl_certfile=${SSL_CLIENT_CERT_PATH}\
&ssl_keyfile=${SSL_CLIENT_KEY_PATH}"

flower -b $REDIS_BROKER_URL
[I 201023 07:20:09 command:140] Visit me at http://localhost:5555
[I 201023 07:20:09 command:145] Broker: redis://:**@xxxx:xxxx//
[I 201023 07:20:09 command:148] Registered tasks:
['celery.accumulate',
'celery.backend_cleanup',
'celery.chain',
'celery.chord',
'celery.chord_unlock',
'celery.chunks',
'celery.group',
'celery.map',
'celery.starmap']
[I 201023 07:20:10 mixins:229] Connected to redis://:**@xxxx:xxxx//
^C^C

关于redis - Flower Broker选项卡中不支持“带有SSL的Redis”代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57872448/

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