Skip to content

Commit

Permalink
Move Redis config to settings file.
Browse files Browse the repository at this point in the history
  • Loading branch information
teleyinex committed Jan 17, 2019
1 parent b666bb8 commit 9b4d5e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pybossa/default_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
REDIS_SENTINEL = [('localhost', 26379)]
REDIS_MASTER = 'mymaster'
REDIS_DB = 0
REDIS_SOCKET_TIMEOUT = 0.1
REDIS_RETRY_ON_TIMEOUT = True

REDIS_KEYPREFIX = 'pybossa_cache'

Expand Down
5 changes: 4 additions & 1 deletion pybossa/sentinel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ def __init__(self, app=None):
self.init_app(app)

def init_app(self, app):
socket_timeout = app.config.get('REDIS_SOCKET_TIMEOUT', 0.1)
retry_on_timeout = app.config.get('REDIS_RETRY_ON_TIMEOUT', True)
self.connection = sentinel.Sentinel(app.config['REDIS_SENTINEL'],
socket_timeout=0.1)
socket_timeout=socket_timeout,
retry_on_timeout=retry_on_timeout)
redis_db = app.config.get('REDIS_DB') or 0
redis_master = app.config.get('REDIS_MASTER') or 'mymaster'
self.master = self.connection.master_for(redis_master, db=redis_db)
Expand Down
2 changes: 2 additions & 0 deletions settings_local.py.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ REDIS_SENTINEL = [('localhost', 26379)]
REDIS_MASTER = 'mymaster'
REDIS_DB = 0
REDIS_KEYPREFIX = 'pybossa_cache'
REDIS_SOCKET_TIMEOUT = 0.1
REDIS_RETRY_ON_TIMEOUT = True

## Allowed upload extensions
ALLOWED_EXTENSIONS = ['js', 'css', 'png', 'jpg', 'jpeg', 'gif', 'zip']
Expand Down

0 comments on commit 9b4d5e4

Please sign in to comment.