Kevin Hu
commited on
Commit
·
294440e
1
Parent(s):
a8e42a7
support monitoring task executor (#2069)
Browse files### What problem does this PR solve?
#1383
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- api/apps/system_app.py +4 -1
- rag/svr/task_executor.py +4 -3
api/apps/system_app.py
CHANGED
|
@@ -68,7 +68,10 @@ def status():
|
|
| 68 |
res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
| 69 |
|
| 70 |
try:
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
color = "green"
|
| 73 |
for id in obj.keys():
|
| 74 |
arr = obj[id]
|
|
|
|
| 68 |
res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)}
|
| 69 |
|
| 70 |
try:
|
| 71 |
+
v = REDIS_CONN.get("TASKEXE")
|
| 72 |
+
if not v:
|
| 73 |
+
raise Exception("No task executor running!")
|
| 74 |
+
obj = json.loads(v)
|
| 75 |
color = "green"
|
| 76 |
for id in obj.keys():
|
| 77 |
arr = obj[id]
|
rag/svr/task_executor.py
CHANGED
|
@@ -379,11 +379,12 @@ def report_status():
|
|
| 379 |
while True:
|
| 380 |
try:
|
| 381 |
obj = REDIS_CONN.get("TASKEXE")
|
| 382 |
-
obj =
|
|
|
|
| 383 |
if id not in obj: obj[id] = []
|
| 384 |
obj[id].append(timer()*1000)
|
| 385 |
-
obj[id] = obj[id][
|
| 386 |
-
REDIS_CONN.set_obj("TASKEXE", obj)
|
| 387 |
except Exception as e:
|
| 388 |
print("[Exception]:", str(e))
|
| 389 |
time.sleep(60)
|
|
|
|
| 379 |
while True:
|
| 380 |
try:
|
| 381 |
obj = REDIS_CONN.get("TASKEXE")
|
| 382 |
+
if not obj: obj = {}
|
| 383 |
+
else: obj = json.load(obj)
|
| 384 |
if id not in obj: obj[id] = []
|
| 385 |
obj[id].append(timer()*1000)
|
| 386 |
+
obj[id] = obj[id][-60:]
|
| 387 |
+
REDIS_CONN.set_obj("TASKEXE", obj, 60*2)
|
| 388 |
except Exception as e:
|
| 389 |
print("[Exception]:", str(e))
|
| 390 |
time.sleep(60)
|