江不江
Kevin Hu
commited on
Commit
·
b994dc1
1
Parent(s):
5ac09ba
fix redis no such key (#1647)
Browse files### What problem does this PR solve?
fix Redis no such key #1614
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
---------
Signed-off-by: seaver <[email protected]>
Co-authored-by: Kevin Hu <[email protected]>
- api/apps/system_app.py +3 -3
- rag/utils/redis_conn.py +7 -2
api/apps/system_app.py
CHANGED
@@ -59,9 +59,9 @@ def status():
|
|
59 |
|
60 |
st = timer()
|
61 |
try:
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
except Exception as e:
|
66 |
res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
67 |
|
|
|
59 |
|
60 |
st = timer()
|
61 |
try:
|
62 |
+
if not REDIS_CONN.health():
|
63 |
+
raise Exception("Lost connection!")
|
64 |
+
res["redis"] = {"status": "green", "elapsed": "{:.1f}".format((timer() - st)*1000.)}
|
65 |
except Exception as e:
|
66 |
res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
67 |
|
rag/utils/redis_conn.py
CHANGED
@@ -44,9 +44,14 @@ class RedisDB:
|
|
44 |
logging.warning("Redis can't be connected.")
|
45 |
return self.REDIS
|
46 |
|
47 |
-
def health(self
|
|
|
48 |
self.REDIS.ping()
|
49 |
-
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def is_alive(self):
|
52 |
return self.REDIS is not None
|
|
|
44 |
logging.warning("Redis can't be connected.")
|
45 |
return self.REDIS
|
46 |
|
47 |
+
def health(self):
|
48 |
+
|
49 |
self.REDIS.ping()
|
50 |
+
a, b = 'xx', 'yy'
|
51 |
+
self.REDIS.set(a, b, 3)
|
52 |
+
|
53 |
+
if self.REDIS.get(a) == b:
|
54 |
+
return True
|
55 |
|
56 |
def is_alive(self):
|
57 |
return self.REDIS is not None
|