Add more configuration options for redis

- `REDIS_HOST` can be specified in the secrets
- Two new secrets: `REDIS_PASSWD` and `REDIS_DB`
This commit is contained in:
Martin Pépin 2017-04-24 21:27:01 +01:00
parent a0fe94e2f4
commit 2aee43e01a
3 changed files with 14 additions and 7 deletions

View file

@ -22,7 +22,8 @@ except KeyError:
# Other secrets
try:
from .secret import (
SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS
SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS,
REDIS_PASSWD, REDIS_DB, REDIS_HOST
)
except ImportError:
raise RuntimeError("Secrets missing")
@ -159,7 +160,10 @@ CHANNEL_LAYERS = {
"default": {
"BACKEND": "asgi_redis.RedisChannelLayer",
"CONFIG": {
"hosts": [(os.environ.get("REDIS_HOST", "localhost"), 6379)],
"hosts": [(
"redis://:{}@{}:6379/{}"
.format(REDIS_PASSWD, REDIS_HOST, REDIS_DB)
)],
},
"ROUTING": "cof.routing.channel_routing",
}