Moved monitoring of last_execution_time to system_stats (#9851)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Tim O'Farrell
2025-07-22 11:32:59 -06:00
committed by GitHub
parent 38ffc85470
commit e045b757fa
5 changed files with 132 additions and 26 deletions

View File

@@ -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()