From 36ea24f77f1c35af4f46303c3a949e0fb7d9353f Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 25 Apr 2019 07:59:30 -0500 Subject: [PATCH 1/2] Update manage.py Make consistent use of get_environ(). --- bin/manage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/manage.py b/bin/manage.py index f032e8c..76e8cfd 100644 --- a/bin/manage.py +++ b/bin/manage.py @@ -19,8 +19,8 @@ from pymongo import MongoClient from pymongo.errors import * -CONSUL_AGENT = os.getenv('CONSUL_AGENT', False) -CONSUL_HOST = ('localhost' if CONSUL_AGENT else os.getenv('CONSUL', 'consul')) +CONSUL_AGENT = bool(get_environ('CONSUL_AGENT', False)) +CONSUL_HOST = ('localhost' if CONSUL_AGENT else get_environ('CONSUL', 'consul')) consul = pyconsul.Consul(host=CONSUL_HOST) logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', From 3e71d444970aafd6512cd3b42454d87f9aaeac87 Mon Sep 17 00:00:00 2001 From: Joel Kuzmarski Date: Thu, 25 Apr 2019 11:22:17 -0500 Subject: [PATCH 2/2] Move usage of get_environ below definition --- bin/manage.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/manage.py b/bin/manage.py index 76e8cfd..ebd6f6b 100644 --- a/bin/manage.py +++ b/bin/manage.py @@ -19,10 +19,6 @@ from pymongo import MongoClient from pymongo.errors import * -CONSUL_AGENT = bool(get_environ('CONSUL_AGENT', False)) -CONSUL_HOST = ('localhost' if CONSUL_AGENT else get_environ('CONSUL', 'consul')) - -consul = pyconsul.Consul(host=CONSUL_HOST) logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', stream=sys.stdout, level=logging.getLevelName( @@ -67,6 +63,11 @@ def get_environ(key, default): # --------------------------------------------------------- +CONSUL_AGENT = bool(get_environ('CONSUL_AGENT', False)) +CONSUL_HOST = ('localhost' if CONSUL_AGENT else get_environ('CONSUL', 'consul')) + +consul = pyconsul.Consul(host=CONSUL_HOST) + SESSION_CACHE_FILE = get_environ('SESSION_CACHE_FILE', '/tmp/mongodb-session') SESSION_NAME = get_environ('SESSION_NAME', 'mongodb-replica-set-lock') SESSION_TTL = int(get_environ('SESSION_TTL', 60))