2018-05-30 11:19:10 -04:00
|
|
|
from django.apps import AppConfig
|
|
|
|
from django.conf import settings
|
2018-11-02 15:20:08 -04:00
|
|
|
from django.core.exceptions import ImproperlyConfigured
|
2019-12-06 11:52:28 -05:00
|
|
|
import redis
|
2018-05-30 11:19:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
class ExtrasConfig(AppConfig):
|
|
|
|
name = "extras"
|
|
|
|
|
|
|
|
def ready(self):
|
2019-04-25 01:09:19 -04:00
|
|
|
|
|
|
|
import extras.signals
|
|
|
|
|
2019-12-06 11:52:28 -05:00
|
|
|
# Check that we can connect to the configured Redis database.
|
|
|
|
try:
|
|
|
|
rs = redis.Redis(
|
|
|
|
host=settings.WEBHOOKS_REDIS_HOST,
|
|
|
|
port=settings.WEBHOOKS_REDIS_PORT,
|
|
|
|
db=settings.WEBHOOKS_REDIS_DATABASE,
|
|
|
|
password=settings.WEBHOOKS_REDIS_PASSWORD or None,
|
|
|
|
ssl=settings.WEBHOOKS_REDIS_SSL,
|
|
|
|
)
|
|
|
|
rs.ping()
|
|
|
|
except redis.exceptions.ConnectionError:
|
|
|
|
raise ImproperlyConfigured(
|
|
|
|
"Unable to connect to the Redis database. Check that the Redis configuration has been defined in "
|
|
|
|
"configuration.py."
|
|
|
|
)
|