d47c04317c
scheduler_status, queue_status, run_verify 추가. MCP 10개 도구 + NanoClaude wrapper + pre-route 키워드. worker.py trace print 제거. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""Document Server diagnostic tools — scheduler and queue status."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
from datetime import datetime, timezone
|
|
|
|
from ..config import HOSTS
|
|
from ..schemas import BaseResult
|
|
from .ssh import run_command, run_local, SSHError, _is_local_host
|
|
|
|
|
|
def _now() -> str:
|
|
return datetime.now(timezone.utc).isoformat()
|
|
|
|
|
|
async def scheduler_status() -> dict:
|
|
"""Get APScheduler job status from Document Server logs."""
|
|
cfg = HOSTS["gpu"]
|
|
cmd = "docker logs hyungi_document_server-fastapi-1 --tail 100 2>&1 | grep -iE 'scheduler|apscheduler|job|trigger|cron|interval' | tail -20"
|
|
|
|
try:
|
|
if _is_local_host(cfg):
|
|
stdout, _ = await run_local(cmd)
|
|
else:
|
|
stdout, _ = await run_command(cfg, cmd)
|
|
except SSHError as e:
|
|
return {"ok": False, "checked_at": _now(), "error_type": e.error_type,
|
|
"error": str(e), "data": [], "summary": ""}
|
|
|
|
lines = [l.strip() for l in stdout.strip().splitlines() if l.strip()]
|
|
return {
|
|
"ok": True,
|
|
"checked_at": _now(),
|
|
"data": lines,
|
|
"summary": f"최근 스케줄러 로그 {len(lines)}줄",
|
|
"error": "",
|
|
}
|
|
|
|
|
|
async def queue_status() -> dict:
|
|
"""Get document processing queue status from Document Server logs."""
|
|
cfg = HOSTS["gpu"]
|
|
cmd = "docker logs hyungi_document_server-fastapi-1 --tail 200 2>&1 | grep -iE 'queue_consumer|pending|processing|completed|stale|batch' | tail -20"
|
|
|
|
try:
|
|
if _is_local_host(cfg):
|
|
stdout, _ = await run_local(cmd)
|
|
else:
|
|
stdout, _ = await run_command(cfg, cmd)
|
|
except SSHError as e:
|
|
return {"ok": False, "checked_at": _now(), "error_type": e.error_type,
|
|
"error": str(e), "data": [], "summary": ""}
|
|
|
|
lines = [l.strip() for l in stdout.strip().splitlines() if l.strip()]
|
|
return {
|
|
"ok": True,
|
|
"checked_at": _now(),
|
|
"data": lines,
|
|
"summary": f"최근 큐 로그 {len(lines)}줄",
|
|
"error": "",
|
|
}
|