Merge pull request #30 from dwinston/add-redis-url-env-var

Allow use of REDIS_URL env var
This commit is contained in:
Nicholas Charriere 2016-09-08 14:44:08 -07:00 committed by GitHub
commit 2f29a5d50f
2 changed files with 10 additions and 4 deletions

View file

@ -66,6 +66,8 @@ need to change this.
`SNAPPASS_REDIS_DB` is the database that you want to use on this redis server. Defaults to db 0 `SNAPPASS_REDIS_DB` is the database that you want to use on this redis server. Defaults to db 0
`REDIS_URL` is optional and, if set, will be used instead of `REDIS_HOST`, `REDIS_PORT`, and `SNAPPASS_REDIS_DB` to configure the Redis client object. For example: redis://username:password@localhost:6379/0
Docker Docker
------ ------

View file

@ -14,10 +14,14 @@ app.secret_key = os.environ.get('SECRET_KEY', 'Secret Key')
app.config.update( app.config.update(
dict(STATIC_URL=os.environ.get('STATIC_URL', 'static'))) dict(STATIC_URL=os.environ.get('STATIC_URL', 'static')))
if os.environ.get('REDIS_URL'):
redis_client = redis.StrictRedis.from_url(os.environ.get('REDIS_URL'))
else:
redis_host = os.environ.get('REDIS_HOST', 'localhost') redis_host = os.environ.get('REDIS_HOST', 'localhost')
redis_port = os.environ.get('REDIS_PORT', 6379) redis_port = os.environ.get('REDIS_PORT', 6379)
redis_db = os.environ.get('SNAPPASS_REDIS_DB', 0) redis_db = os.environ.get('SNAPPASS_REDIS_DB', 0)
redis_client = redis.StrictRedis(host=redis_host, port=redis_port, db=redis_db) redis_client = redis.StrictRedis(
host=redis_host, port=redis_port, db=redis_db)
time_conversion = { time_conversion = {
'week': 604800, 'week': 604800,