Skip to content

Commit

Permalink
RedisClient: Try to ping on init
Browse files Browse the repository at this point in the history
  • Loading branch information
jareddantis committed Oct 8, 2023
1 parent 59a9188 commit 18ef29f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions database/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ def __init__(self, host: str, port: int, password: Optional[str] = None):

# Logger
self._logger = create_logger(self.__class__.__name__)
self._logger.debug('Attempting to connect to Redis server...')

# Test connection
try:
self._client.ping()
except redis.ConnectionError as err:
self._logger.critical('Could not connect to Redis server. Check your configuration.')
raise RuntimeError('Could not connect to Redis server.') from err

self._logger.info('Connected to Redis server. Enable debug logging to see cache hits.')

def set_lavalink_track(self, key: str, value: str, *, key_type: str):
Expand Down

0 comments on commit 18ef29f

Please sign in to comment.