feat: add tool-call fallback and resilient batch exports
This commit is contained in:
1 parent
ab066733b8
commit
d31eb2a19d
32 files changed
+538
-72
No files matched your search
@@ -517,9 +517,12 @@ async def get_model_config_and_env():
|
||||
|
||||
@router.get("/server-status")
|
||||
async def get_server_runtime_status():
|
||||
"""Retrieve runtime status, PID, port, and uptime of the Artemis server."""
|
||||
"""Return this server's status without scanning listening ports."""
|
||||
import os
|
||||
from artemis.runtime.server_lifecycle import get_server_status
|
||||
import time
|
||||
|
||||
from artemis.runtime.process_probe import pid_is_alive
|
||||
from artemis.runtime.server_lifecycle import read_server_info
|
||||
|
||||
try:
|
||||
from apps.admin_console.core.state import state
|
||||
@@ -527,18 +530,34 @@ async def get_server_runtime_status():
|
||||
from admin_console.core.state import state
|
||||
|
||||
port = getattr(state, "port", 8000)
|
||||
status = get_server_status(port=port)
|
||||
current_pid = os.getpid()
|
||||
pids = {current_pid}
|
||||
started_at = None
|
||||
info = read_server_info()
|
||||
if info and info.get("port") == port:
|
||||
saved_pid = info.get("pid")
|
||||
if isinstance(saved_pid, int) and saved_pid != current_pid and pid_is_alive(saved_pid):
|
||||
pids.add(saved_pid)
|
||||
if saved_pid == current_pid and isinstance(info.get("started_at"), (int, float)):
|
||||
started_at = float(info["started_at"])
|
||||
if started_at is None:
|
||||
try:
|
||||
import psutil
|
||||
|
||||
started_at = psutil.Process(current_pid).create_time()
|
||||
except Exception:
|
||||
started_at = None
|
||||
# Explicit DTO: the raw metadata file additionally holds the lifecycle
|
||||
# token, cmdline, and filesystem paths, none of which belong on the wire.
|
||||
return {
|
||||
"running": status["running"],
|
||||
"port": status["port"],
|
||||
"pids": status["pids"],
|
||||
"active_pid": status["active_pid"],
|
||||
"uptime_seconds": status["uptime_seconds"],
|
||||
"url": status["url"],
|
||||
"admin_url": status["admin_url"],
|
||||
"current_pid": os.getpid(),
|
||||
"running": True,
|
||||
"port": port,
|
||||
"pids": sorted(pids),
|
||||
"active_pid": current_pid,
|
||||
"uptime_seconds": max(0.0, time.time() - started_at) if started_at else None,
|
||||
"url": f"http://localhost:{port}",
|
||||
"admin_url": f"http://localhost:{port}/admin",
|
||||
"current_pid": current_pid,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user