diff options
| author | 2020-05-17 19:50:12 +0200 | |
|---|---|---|
| committer | 2020-05-17 19:55:05 +0200 | |
| commit | ecf7f24f05b9baa8705f3b2c2d044a42292fbc07 (patch) | |
| tree | 39da17d2e469c27329eba191789b1b45dc855c89 | |
| parent | Changes discord-py to discord.py in Pipfile (diff) | |
Add the REDIS_PASSWORD environment variable
In production, we will need this password to make a connection to Redis.
| -rw-r--r-- | bot/constants.py | 11 | ||||
| -rw-r--r-- | bot/utils/redis_dict.py | 5 | ||||
| -rw-r--r-- | config-default.yml | 7 | 
3 files changed, 17 insertions, 6 deletions
| diff --git a/bot/constants.py b/bot/constants.py index 01e8ac3a3..5d854dd7a 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -199,8 +199,15 @@ class Bot(metaclass=YAMLGetter):      prefix: str      token: str      sentry_dsn: str -    redis_host: str -    redis_port: int + + +class Redis(metaclass=YAMLGetter): +    section = "bot" +    subsection = "redis" + +    host: str +    port: int +    password: str  class Filter(metaclass=YAMLGetter): diff --git a/bot/utils/redis_dict.py b/bot/utils/redis_dict.py index 47905314a..4a5e34249 100644 --- a/bot/utils/redis_dict.py +++ b/bot/utils/redis_dict.py @@ -27,8 +27,9 @@ class RedisDict(MutableMapping):      _namespaces = []      _redis = redis_py.Redis( -        host=constants.Bot.redis_host, -        port=constants.Bot.redis_port, +        host=constants.Redis.host, +        port=constants.Redis.port, +        password=constants.Redis.password,      )  # Can be overridden for testing      def __init__(self, namespace: Optional[str] = None) -> None: diff --git a/config-default.yml b/config-default.yml index 722afa41b..3b58d9099 100644 --- a/config-default.yml +++ b/config-default.yml @@ -2,8 +2,11 @@ bot:      prefix:      "!"      token:       !ENV "BOT_TOKEN"      sentry_dsn:  !ENV "BOT_SENTRY_DSN" -    redis_host:  "redis" -    redis_port:  6379 + +    redis: +        host:  "redis" +        port:  6379 +        password: !ENV "REDIS_PASSWORD"      stats:          statsd_host: "graphite" | 
