-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a6a42d
commit c4edcdd
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import sys | ||
import time | ||
|
||
from django.conf import settings | ||
|
||
import redis | ||
|
||
|
||
def ping_redis(): | ||
redis.Redis.from_url(settings.BROKER_URL).ping() | ||
|
||
|
||
def exit_if_redis_down(logger): | ||
try: | ||
ping_redis() | ||
except redis.ConnectionError as exc: | ||
logger.info(f'Redis ping error: {exc}') | ||
time.sleep(1) # Patience to avoid log spam | ||
sys.exit(1) | ||