Files
momentry_core/static/monitor/app.js
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

105 lines
3.0 KiB
JavaScript

function monitorApp() {
return {
// Data
lastUpdate: 'Never',
queue: { pending: 0, running: 0, completed: 0, failed: 0 },
runningJobs: [],
worker: {
cpu_percent: 0,
gpu_percent: 0,
memory_mb: 0,
memory_percent: 0,
active_processors: 0,
max_processors: 6,
processors: []
},
// Initialize
init() {
this.refresh();
setInterval(() => this.refresh(), 5000);
},
// Refresh all data
async refresh() {
await Promise.all([
this.fetchQueueStats(),
this.fetchRunningJobs(),
this.fetchWorkerStatus()
]);
this.lastUpdate = new Date().toLocaleTimeString();
},
// Fetch queue stats
async fetchQueueStats() {
try {
const res = await fetch('/api/v1/monitor/queue_stats');
this.queue = await res.json();
} catch (e) {
console.error('Failed to fetch queue stats:', e);
}
},
// Fetch running jobs
async fetchRunningJobs() {
try {
const res = await fetch('/api/v1/monitor/running_jobs');
const data = await res.json();
this.runningJobs = data.jobs;
} catch (e) {
console.error('Failed to fetch running jobs:', e);
}
},
// Fetch worker status
async fetchWorkerStatus() {
try {
const res = await fetch('/api/v1/monitor/worker_status');
this.worker = await res.json();
} catch (e) {
console.error('Failed to fetch worker status:', e);
}
},
// Helper functions
getPhaseName(phase) {
const names = {
1: 'Foundation',
2: 'Core Processing',
3: 'Deep Analysis',
4: 'Knowledge Building'
};
return names[phase] || '';
},
getProcessorIcon(status) {
const icons = {
'completed': '✅',
'running': '🔄',
'pending': '⏸️',
'deferred': '⏸️',
'failed': '❌'
};
return icons[status] || '❓';
},
getProcessorColor(status) {
const colors = {
'completed': 'bg-green-500',
'running': 'bg-blue-500',
'pending': 'bg-gray-500',
'deferred': 'bg-yellow-500',
'failed': 'bg-red-500'
};
return colors[status] || 'bg-gray-500';
},
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`;
}
}
}