在我的 django 应用程序中使用 celery 和 redis
一切都工作正常,直到我遇到了问题。 redis 文件的位置已更改,redis 无法访问它们。经过查找,原来这是由于网络随机攻击造成的,需要添加confg
我添加文件后,一段时间都工作得很好,然后就出现了这个问题
1:S 25 Jun 2021 00:48:12.029 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:12.901 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:12.902 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:13.034 # Error condition on socket for SYNC: Connection refused
1:S 25 Jun 2021 00:48:13.907 * Connecting to MASTER 194.38.20.199:8886
1:S 25 Jun 2021 00:48:13.908 * MASTER <-> REPLICA sync started
1:S 25 Jun 2021 00:48:14.041 # Error condition on socket for SYNC: Connection refused
当我重建 Redis 容器时,它运行了很短的时间,并且遇到了同样的问题
设置.py
CELERY_BROKER_URL = os.environ.get("redis://redis:6379/0")
CELERY_RESULT_BACKEND = os.environ.get("redis://redis:6379/0")
docker-compose.yml
redis:
image: 'redis:alpine'
restart: unless-stopped
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
ports:
- '6379:6379'
celery:
restart: unless-stopped
build:
context: .
dockerfile: ./docker/backend/Dockerfile_celery
entrypoint: /app/docker/backend/celery-entrypoint.sh
environment:
- some env vars
depends_on:
- asgiserver
- redis
redis.conf
bind 0.0.0.0
protected-mode yes
rename-command CONFIG ""
通过改变解决ports
配置为expose
as 伊恩谢尔文顿上文提到的
redis:
image: 'redis:alpine'
restart: unless-stopped
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./docker/redis/redis.conf:/usr/local/etc/redis/redis.conf
expose:
- 6379
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)