fix: 修复实时日志与数据库切换可靠性
Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
Sync LobeHub models / sync (push) Has been cancelled
Axolotl desktop CI / guardrails (push) Has been cancelled
Axolotl desktop CI / desktop (macos-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (ubuntu-latest) (push) Has been cancelled
Axolotl desktop CI / desktop (windows-latest) (push) Has been cancelled
Axolotl desktop CI / website (push) Has been cancelled
Repository checks / typos (push) Has been cancelled
Repository checks / tombi (push) Has been cancelled
Rust checks / shear (push) Has been cancelled
Sync source to CNB / Sync Git ref (push) Has been cancelled
Sync LobeHub models / sync (push) Has been cancelled
This commit is contained in:
1 parent
2efaa4fb35
commit
ce0f41c973
30 files changed
+814
-461
No files matched your search
@@ -86,13 +86,16 @@ const {
|
||||
getHistoricalContent,
|
||||
invalidate,
|
||||
clearLive,
|
||||
refreshLive,
|
||||
flushLive,
|
||||
acceptsProcessLogs,
|
||||
resetLive,
|
||||
appendLive,
|
||||
resyncLive,
|
||||
} = useInstanceConsole(instanceId.value)
|
||||
|
||||
await hydrate()
|
||||
const unlistenLog = await log_listener((payload) => {
|
||||
if (payload.instance_id !== instanceId.value) return
|
||||
void appendLive(payload)?.catch(console.warn)
|
||||
})
|
||||
|
||||
await hydrate().catch(handleError)
|
||||
|
||||
function buildLogList(rawLogs) {
|
||||
return [
|
||||
@@ -219,28 +222,16 @@ if (!props.playing) {
|
||||
void analyseForCrash()
|
||||
}
|
||||
|
||||
const unlistenLog = await log_listener((payload) => {
|
||||
if (payload.instance_id !== instanceId.value) return
|
||||
if (!acceptsProcessLogs()) return
|
||||
|
||||
if (payload.type === 'log4j') {
|
||||
liveConsole.addLog4jEvent(payload)
|
||||
} else if (payload.type === 'legacy') {
|
||||
void liveConsole.addLegacyLog(payload.message)
|
||||
}
|
||||
})
|
||||
|
||||
const unlistenProcesses = await process_listener(async (e) => {
|
||||
if (e.instance_id !== instanceId.value) return
|
||||
if (e.event === 'launched') {
|
||||
resetLive()
|
||||
await resyncLive().catch(console.warn)
|
||||
clearCrashAnalysis()
|
||||
invalidate()
|
||||
selectedLogIndex.value = 0
|
||||
}
|
||||
if (e.event === 'finished') {
|
||||
await refreshLive().catch(console.warn)
|
||||
flushLive()
|
||||
await resyncLive().catch(console.warn)
|
||||
invalidate()
|
||||
const freshLogs = await getHistoricalLogs()
|
||||
logs.value = buildLogList(freshLogs)
|
||||
@@ -248,20 +239,7 @@ const unlistenProcesses = await process_listener(async (e) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Keep following the file even when a mod stops writing to stdout after startup.
|
||||
// Schedule after each read so slow disk/IPC cannot pile up concurrent requests.
|
||||
let disposed = false
|
||||
let refreshTimer
|
||||
async function followLatestLog() {
|
||||
await refreshLive().catch(console.warn)
|
||||
if (!props.playing) flushLive()
|
||||
if (!disposed) refreshTimer = setTimeout(followLatestLog, 1000)
|
||||
}
|
||||
void followLatestLog()
|
||||
|
||||
onUnmounted(() => {
|
||||
disposed = true
|
||||
clearTimeout(refreshTimer)
|
||||
unlistenLog()
|
||||
unlistenProcesses()
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user