mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-19 11:52:22 -06:00
Tweaked webhooks and Redis settings
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
from django.core.cache import caches
|
||||
from django.db.utils import ProgrammingError
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.conf import settings
|
||||
|
||||
@@ -13,17 +11,25 @@ class ExtrasConfig(AppConfig):
|
||||
def ready(self):
|
||||
import extras.signals
|
||||
|
||||
# check that we can connect to redis
|
||||
if settings.WEBHOOK_BACKEND_ENABLED:
|
||||
# Check that we can connect to the configured Redis database if webhooks are enabled.
|
||||
if settings.WEBHOOKS_ENABLED:
|
||||
try:
|
||||
import redis
|
||||
rs = redis.Redis(settings.REDIS_HOST,
|
||||
settings.REDIS_PORT,
|
||||
settings.REDIS_DB,
|
||||
settings.REDIS_PASSWORD or None)
|
||||
except ImportError:
|
||||
raise ImproperlyConfigured(
|
||||
"WEBHOOKS_ENABLED is True but the redis Python package is not installed. (Try 'pip install "
|
||||
"redis'.)"
|
||||
)
|
||||
try:
|
||||
rs = redis.Redis(
|
||||
host=settings.REDIS_HOST,
|
||||
port=settings.REDIS_PORT,
|
||||
db=settings.REDIS_DATABASE,
|
||||
password=settings.REDIS_PASSWORD or None,
|
||||
)
|
||||
rs.ping()
|
||||
except redis.exceptions.ConnectionError:
|
||||
raise ImproperlyConfigured(
|
||||
"Unable to connect to the redis database. You must provide "
|
||||
"connection settings to redis per the documentation."
|
||||
"Unable to connect to the Redis database. Check that the Redis configuration has been defined in "
|
||||
"configuration.py."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user