django - Django Celery Heroku - 更改了 Redis URL 环境变量,现在出现错误
问题描述
我更新了环境变量,在 Heroku 中称为 REDDIS_URL 的配置变量
我关闭了我的应用测功机和我的工人测功机。
然后我重新启动了我的应用程序测功机,web gunicorn myapplication.wsgi
没有任何问题
然后我重新启动了我的工作人员worker celery -A myapplication worker -l info --concurrency 2
,这导致我在日志中收到以下错误[2021-07-06 16:00:05: ERROR/MainProcess] Cannot connect to redis://NEW_REDDIS_URL//: Error while reading from socket: (104, 'Connection reset by peer').
如何让工作人员为 REDDIS_URL 引用更新的配置变量(环境变量)?
解决方案
使用 OS 在 settings.py 中设置你的 redis URL 是一个好习惯os.environ.get('REDIS_URL')
Heroku 会定期轮换凭证并更新附加此数据存储的应用程序。
Heroku 建议使用加密,因此建议使用rediss://
URL 而不是redis://
对于芹菜,类似:CELERY_BROKER_URL ='rediss://:{Password}@{Host}:{Port}'
Heroku 命令轻松获取此网址heroku redis:credentials REDIS_URL
参考:https ://devcenter.heroku.com/articles/heroku-redis#using-the-cli
推荐阅读
- driver - Windows HID 属性 IOCTL 如何在 Windows 中工作?
- windows - 在windows arm上设置雪花odbc?
- swiftui - 当布尔值为真时触发动画
- c - Win32 API Ncrypt 和 Bcrypt 的使用:为什么教程代码在一个非常简单的变化后失败了?
- ios - Instagram Reels 快速查看评论
- java - 按值对 TreeMap 进行排序
- reactjs - 反应路由器不渲染路由
- java - 解决方案而不是写一堆 if
- python - 如何使用 isinstance 测试所有可能的整数类型
- python - TypeError:“str”和“int”的实例之间不支持“>”。可能有 float 或 int