Files
momentry_core/static/monitor/standalone.html
T
Accusys c151b49334 feat: implement service management API for VLM control
- Add /api/v1/mbe/health endpoint for status checks
- Add /api/v2/service/start to start llama-server
- Add /api/v2/service/stop to stop llama-server
- Use TCP connection test for port detection (more reliable than lsof)
- Add ps aux fallback for PID detection
- Implement structured bilingual VLM tags
- Add VLM integration documentation for Studio team

Endpoints tested and working with Momentry Studio AdminView UI.
2026-10-24 02:37:53 +08:00

245 lines
10 KiB
HTML

<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Momentry Monitor</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0f172a;
color: #e2e8f0;
padding: 20px;
}
.container { max-width: 1200px; margin: 0 auto; }
h1 { font-size: 2rem; margin-bottom: 1rem; }
h2 { font-size: 1.5rem; margin: 1rem 0; }
.card {
background: #1e293b;
border-radius: 8px;
padding: 1.5rem;
margin-bottom: 1rem;
}
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; text-align: center; }
.stat { padding: 1rem; }
.stat-value { font-size: 2rem; font-weight: bold; }
.stat-label { color: #94a3b8; font-size: 0.875rem; }
.text-yellow { color: #fbbf24; }
.text-blue { color: #60a5fa; }
.text-green { color: #34d399; }
.text-red { color: #f87171; }
.job { border: 1px solid #334155; border-radius: 8px; padding: 1rem; margin: 0.5rem 0; }
.processor {
background: #334155;
border-radius: 4px;
padding: 0.5rem;
margin: 0.25rem 0;
font-size: 0.875rem;
}
.status-completed { color: #34d399; }
.status-running { color: #60a5fa; }
.status-pending { color: #fbbf24; }
.status-failed { color: #f87171; }
.progress-bar {
background: #475569;
border-radius: 9999px;
height: 8px;
overflow: hidden;
margin: 0.25rem 0;
}
.progress-fill { height: 100%; transition: width 0.3s; }
.refresh-btn {
background: #3b82f6;
color: white;
border: none;
padding: 0.5rem 1rem;
border-radius: 6px;
cursor: pointer;
}
.refresh-btn:hover { background: #2563eb; }
</style>
</head>
<body>
<div class="container">
<header style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;">
<div>
<h1>Momentry Monitor</h1>
<p style="color: #94a3b8; font-size: 0.875rem;">
Last updated: <span id="lastUpdate">Never</span>
</p>
</div>
<button class="refresh-btn" onclick="refresh()">Refresh</button>
</header>
<div class="card">
<h2>Queue Overview</h2>
<div class="grid">
<div class="stat">
<div class="stat-value text-yellow" id="pending">0</div>
<div class="stat-label">Pending</div>
</div>
<div class="stat">
<div class="stat-value text-blue" id="running">0</div>
<div class="stat-label">Running</div>
</div>
<div class="stat">
<div class="stat-value text-green" id="completed">0</div>
<div class="stat-label">Completed</div>
</div>
<div class="stat">
<div class="stat-value text-red" id="failed">0</div>
<div class="stat-label">Failed</div>
</div>
</div>
</div>
<div class="card">
<h2>Running Jobs</h2>
<div id="jobs">Loading...</div>
</div>
<div class="card">
<h2>Worker Resources</h2>
<div>
<div>CPU: <span id="cpu">0</span>%</div>
<div class="progress-bar">
<div class="progress-fill" id="cpu-bar" style="width: 0%; background: #3b82f6;"></div>
</div>
</div>
<div style="margin-top: 0.5rem;">
<div>GPU: <span id="gpu">0</span>%</div>
<div class="progress-bar">
<div class="progress-fill" id="gpu-bar" style="width: 0%; background: #34d399;"></div>
</div>
</div>
<div style="margin-top: 0.5rem;">
<div>Memory: <span id="memory">0</span> MB (<span id="memory-pct">0</span>%)</div>
<div class="progress-bar">
<div class="progress-fill" id="memory-bar" style="width: 0%; background: #a855f7;"></div>
</div>
</div>
<div style="margin-top: 1rem;">
Active Processors: <span id="active-proc">0</span> / <span id="max-proc">6</span>
</div>
</div>
</div>
<script>
const phaseNames = {
1: 'Foundation',
2: 'Core Processing',
3: 'Deep Analysis',
4: 'Knowledge Building'
};
const statusIcons = {
'completed': '✓',
'running': '🔄',
'pending': '⏸',
'failed': '✗'
};
async function refresh() {
try {
// Queue Stats
const queueRes = await fetch('/api/v1/monitor/queue_stats');
const queue = await queueRes.json();
document.getElementById('pending').textContent = queue.pending;
document.getElementById('running').textContent = queue.running;
document.getElementById('completed').textContent = queue.completed;
document.getElementById('failed').textContent = queue.failed;
// Running Jobs
const jobsRes = await fetch('/api/v1/monitor/running_jobs');
const jobsData = await jobsRes.json();
let jobsHtml = '';
if (jobsData.jobs.length === 0) {
jobsHtml = '<div style="color: #94a3b8; padding: 2rem; text-align: center;">No jobs currently running</div>';
} else {
jobsData.jobs.forEach(job => {
const duration = formatDuration(job.duration_secs);
// Group processors by phase
const phases = {};
job.processors.forEach(p => {
const phase = p.phase || 0;
if (!phases[phase]) phases[phase] = [];
phases[phase].push(p);
});
jobsHtml += `
<div class="job">
<div style="display: flex; justify-content: space-between; margin-bottom: 1rem;">
<div>
<div style="font-size: 1.25rem; font-weight: bold;">
Job #${job.job_id}
</div>
<div style="color: #94a3b8; font-size: 0.875rem;">
${job.file_name || 'Unknown file'} | UUID: ${job.file_uuid}
</div>
</div>
<div style="text-align: right;">
<div style="color: #94a3b8; font-size: 0.875rem;">Duration</div>
<div style="font-weight: bold;">${duration}</div>
</div>
</div>
<div>
${Object.entries(phases).sort(([a], [b]) => a - b).map(([phase, procs]) => `
<div style="margin: 0.5rem 0;">
<div style="font-weight: bold; margin-bottom: 0.25rem;">
Phase ${phase}: ${phaseNames[phase] || 'Other'}
</div>
<div style="display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.5rem;">
${procs.map(p => `
<div class="processor status-${p.status}">
${statusIcons[p.status] || '?'} ${p.name}: ${p.status} (${p.progress}%)
</div>
`).join('')}
</div>
</div>
`).join('')}
</div>
</div>
`;
});
}
document.getElementById('jobs').innerHTML = jobsHtml;
// Worker Status
const workerRes = await fetch('/api/v1/monitor/worker_status');
const worker = await workerRes.json();
document.getElementById('cpu').textContent = worker.cpu_percent.toFixed(1);
document.getElementById('cpu-bar').style.width = worker.cpu_percent + '%';
document.getElementById('gpu').textContent = worker.gpu_percent.toFixed(1);
document.getElementById('gpu-bar').style.width = worker.gpu_percent + '%';
document.getElementById('memory').textContent = worker.memory_mb;
document.getElementById('memory-pct').textContent = worker.memory_percent.toFixed(1);
document.getElementById('memory-bar').style.width = worker.memory_percent + '%';
document.getElementById('active-proc').textContent = worker.active_processors;
document.getElementById('max-proc').textContent = worker.max_processors;
document.getElementById('lastUpdate').textContent = new Date().toLocaleTimeString();
} catch (e) {
console.error('Error:', e);
}
}
function formatDuration(secs) {
if (!secs) return '0s';
const m = Math.floor(secs / 60);
const s = Math.floor(secs % 60);
return m > 0 ? `${m}m ${s}s` : `${s}s`;
}
refresh();
setInterval(refresh, 5000);
</script>
</body>
</html>