mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
Moved monitoring of last_execution_time to system_stats (#9851)
Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import time
|
||||
from fastapi import FastAPI
|
||||
|
||||
from fastapi import FastAPI, Request
|
||||
|
||||
from openhands.runtime.utils.system_stats import get_system_stats
|
||||
|
||||
start_time = time.time()
|
||||
last_execution_time = start_time
|
||||
from openhands.runtime.utils.system_stats import get_system_info
|
||||
|
||||
|
||||
def add_health_endpoints(app: FastAPI):
|
||||
@@ -19,20 +14,4 @@ def add_health_endpoints(app: FastAPI):
|
||||
|
||||
@app.get('/server_info')
|
||||
async def get_server_info():
|
||||
current_time = time.time()
|
||||
uptime = current_time - start_time
|
||||
idle_time = current_time - last_execution_time
|
||||
|
||||
response = {
|
||||
'uptime': uptime,
|
||||
'idle_time': idle_time,
|
||||
'resources': get_system_stats(),
|
||||
}
|
||||
return response
|
||||
|
||||
@app.middleware('http')
|
||||
async def update_last_execution_time(request: Request, call_next):
|
||||
global last_execution_time
|
||||
response = await call_next(request)
|
||||
last_execution_time = time.time()
|
||||
return response
|
||||
return get_system_info()
|
||||
|
||||
Reference in New Issue
Block a user