From dbf5844f6a996399b2227f57a136a39897002673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Delobelle?= Date: Sat, 15 Apr 2017 14:41:55 +0200 Subject: [PATCH] Clean settings redis --- cof/settings/common.py | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cof/settings/common.py b/cof/settings/common.py index 98f4f713..a3b7527f 100644 --- a/cof/settings/common.py +++ b/cof/settings/common.py @@ -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 + '/' + + # 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"