feat: fix MBE health check and add model selection dropdown
- Fixed testMbe() to always use /health instead of /v1/health
- Added model selection dropdown for MarkBaseEngine
- Modified startService('mbe') to pass model and port parameters
- Added loadMbeModels() to fetch available models on mount
- Added getApiBase import
This commit is contained in:
@@ -497,6 +497,11 @@
|
|||||||
<input class="settings-input" v-model="mbeUrl" placeholder="http://localhost:8080" />
|
<input class="settings-input" v-model="mbeUrl" placeholder="http://localhost:8080" />
|
||||||
<button class="settings-test-btn" @click="testMbe" :disabled="testingMbe">{{ testingMbe ? 'Testing...' : 'Test' }}</button>
|
<button class="settings-test-btn" @click="testMbe" :disabled="testingMbe">{{ testingMbe ? 'Testing...' : 'Test' }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="service-row" style="margin-top: 8px;">
|
||||||
|
<select v-model="mbeSelectedModel" class="settings-input" :disabled="mbeActionLoading || mbeModels.length === 0">
|
||||||
|
<option v-for="m in mbeModels" :key="m.dir" :value="m.dir">{{ m.name }}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="service-actions">
|
<div class="service-actions">
|
||||||
<button class="service-stop-btn" @click="stopService('mbe')" :disabled="mbeActionLoading">Stop</button>
|
<button class="service-stop-btn" @click="stopService('mbe')" :disabled="mbeActionLoading">Stop</button>
|
||||||
<button class="service-start-btn" @click="startService('mbe')" :disabled="mbeActionLoading">Start</button>
|
<button class="service-start-btn" @click="startService('mbe')" :disabled="mbeActionLoading">Start</button>
|
||||||
@@ -560,6 +565,7 @@
|
|||||||
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
|
import { ref, onMounted, onUnmounted, watch, computed } from 'vue'
|
||||||
import { apiCall } from '../api'
|
import { apiCall } from '../api'
|
||||||
import { loadSystemStats, systemStatsCache, SystemStats } from '../store'
|
import { loadSystemStats, systemStatsCache, SystemStats } from '../store'
|
||||||
|
import { getApiBase } from '@/api/config'
|
||||||
|
|
||||||
const activeTab = ref('dashboard')
|
const activeTab = ref('dashboard')
|
||||||
const stats = ref({ cpu: 0, memory: 0, disk: 0 })
|
const stats = ref({ cpu: 0, memory: 0, disk: 0 })
|
||||||
@@ -686,6 +692,10 @@ const markbaseUrl = ref('http://localhost:11438')
|
|||||||
const mbeUrl = ref('http://localhost:8080')
|
const mbeUrl = ref('http://localhost:8080')
|
||||||
const proxyUrl = ref('http://localhost:8888')
|
const proxyUrl = ref('http://localhost:8888')
|
||||||
const workerUrl = ref('http://localhost:11438')
|
const workerUrl = ref('http://localhost:11438')
|
||||||
|
|
||||||
|
// MBE Models
|
||||||
|
const mbeModels = ref<Array<{id: string, dir: string, name: string}>>([])
|
||||||
|
const mbeSelectedModel = ref('E4B-MarkBase')
|
||||||
const coreStatus = ref('unknown')
|
const coreStatus = ref('unknown')
|
||||||
const mbStatus = ref('unknown')
|
const mbStatus = ref('unknown')
|
||||||
const mbeStatus = ref('unknown')
|
const mbeStatus = ref('unknown')
|
||||||
@@ -742,7 +752,12 @@ async function startService(name: string) {
|
|||||||
s.loading.value = true
|
s.loading.value = true
|
||||||
s.result.value = ''
|
s.result.value = ''
|
||||||
try {
|
try {
|
||||||
const result = await apiCall('start_service', { name })
|
const args: any = { name }
|
||||||
|
if (name === 'mbe') {
|
||||||
|
args.model = mbeSelectedModel.value
|
||||||
|
args.port = 8080
|
||||||
|
}
|
||||||
|
const result = await apiCall('start_service', args)
|
||||||
const started = typeof result === 'string' ? result === 'started' : result?.result === 'started'
|
const started = typeof result === 'string' ? result === 'started' : result?.result === 'started'
|
||||||
s.result.value = started ? (name === 'mbe' ? 'Loading model...' : 'Service started') : JSON.stringify(result)
|
s.result.value = started ? (name === 'mbe' ? 'Loading model...' : 'Service started') : JSON.stringify(result)
|
||||||
s.ok.value = started
|
s.ok.value = started
|
||||||
@@ -864,8 +879,9 @@ async function testMbe() {
|
|||||||
testingMbe.value = true
|
testingMbe.value = true
|
||||||
mbeInfo.value = null
|
mbeInfo.value = null
|
||||||
try {
|
try {
|
||||||
const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
// MarkBaseServer only exposes /health (returns plain text "OK")
|
||||||
const healthUrl = isLocalhost ? `${mbeUrl.value}/health` : `${mbeUrl.value}/v1/health`
|
// Always use /health regardless of hostname
|
||||||
|
const healthUrl = `${mbeUrl.value.replace(/\/$/, '')}/health`
|
||||||
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
const resp = await fetch(healthUrl, { signal: AbortSignal.timeout(5000) })
|
||||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||||
|
|
||||||
@@ -884,7 +900,7 @@ async function testMbe() {
|
|||||||
} else {
|
} else {
|
||||||
// 纯文本格式响应
|
// 纯文本格式响应
|
||||||
const text = await resp.text()
|
const text = await resp.text()
|
||||||
isHealthy = text === 'OK' || text.includes('"status":"ok"')
|
isHealthy = text.trim() === 'OK' || text.includes('"status":"ok"')
|
||||||
mbeInfo.value = { version: 'MarkBaseEngine', uptime: 0 }
|
mbeInfo.value = { version: 'MarkBaseEngine', uptime: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,8 +1209,26 @@ async function saveConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadMbeModels() {
|
||||||
|
try {
|
||||||
|
const base = getApiBase()
|
||||||
|
const res = await fetch(`${base}/api/v2/mbe/models`, { signal: AbortSignal.timeout(5000) })
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json()
|
||||||
|
if (data.models && data.models.length > 0) {
|
||||||
|
mbeModels.value = data.models
|
||||||
|
mbeSelectedModel.value = data.default || data.models[0].dir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Silently fail - models list is optional
|
||||||
|
console.error('Failed to load MBE models:', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadServiceUrls()
|
loadServiceUrls()
|
||||||
|
await loadMbeModels()
|
||||||
await Promise.all([loadDashboard(), loadUsers(), loadShares(), loadSettings()])
|
await Promise.all([loadDashboard(), loadUsers(), loadShares(), loadSettings()])
|
||||||
await Promise.all([testCoreApi(), testMarkbase(), testMbe(), testProxy(), testWorker()])
|
await Promise.all([testCoreApi(), testMarkbase(), testMbe(), testProxy(), testWorker()])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user