forked from DGNum/gestioCOF
Clean settings redis
This commit is contained in:
parent
e772d12721
commit
dbf5844f6a
1 changed files with 20 additions and 12 deletions
|
@ -19,6 +19,26 @@ except ImportError:
|
|||
except KeyError:
|
||||
raise RuntimeError("Secrets missing")
|
||||
|
||||
|
||||
# Redis settings (for cache and channel layers)
|
||||
try:
|
||||
from .secret import REDIS_USER, REDIS_PASS
|
||||
except ImportError:
|
||||
REDIS_USER = os.environ.get("REDIS_USER", "")
|
||||
REDIS_PASS = os.environ.get("REDIS_PASS", "")
|
||||
|
||||
if REDIS_USER or REDIS_PASS:
|
||||
REDIS_AUTH = REDIS_USER+":"+REDIS_PASS+"@"
|
||||
else:
|
||||
REDIS_AUTH = ''
|
||||
|
||||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
||||
|
||||
REDIS_BASE_URL = "redis://" + REDIS_AUTH + REDIS_HOST + ":" + REDIS_PORT
|
||||
# To select a specific redis database, do: REDIS_BASE_URL + '/<num_db>'
|
||||
|
||||
|
||||
# Other secrets
|
||||
try:
|
||||
from .secret import (
|
||||
|
@ -153,18 +173,6 @@ AUTHENTICATION_BACKENDS = (
|
|||
|
||||
RECAPTCHA_USE_SSL = True
|
||||
|
||||
|
||||
# Redis settings (for cache and channel layers)
|
||||
|
||||
REDIS_HOST = os.environ.get("REDIS_HOST", "localhost")
|
||||
REDIS_USER = os.environ.get("REDIS_USER", "")
|
||||
REDIS_PASS = os.environ.get("REDIS_PASS", "")
|
||||
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
|
||||
|
||||
REDIS_AUTH = REDIS_USER+":"+REDIS_PASS+"@" if REDIS_USER or REDIS_PASS else ''
|
||||
REDIS_BASE_URL = "redis://" + REDIS_AUTH + REDIS_HOST + ":" + REDIS_PORT
|
||||
|
||||
|
||||
# Cache settings (use db #1 of redis)
|
||||
|
||||
CACHE_REDIS_URL = REDIS_BASE_URL + "/1"
|
||||
|
|
Loading…
Reference in a new issue