Merge pull request #4201 from janhq/fix/4155-queue-up-health-check-on-server-restart

fix: 4155 - Queue up health check on server restarting
This commit is contained in:
Louis 2024-12-03 17:37:07 +07:00 committed by GitHub
commit 9e634c783f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -334,13 +334,22 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
} }
}) })
/**
* This is to handle the server segfault issue
*/
this.socket.onclose = (event) => { this.socket.onclose = (event) => {
console.log('WebSocket closed:', event) console.log('WebSocket closed:', event)
// Notify app to update model running state
events.emit(ModelEvent.OnModelStopped, {}) events.emit(ModelEvent.OnModelStopped, {})
// Reconnect to the /events websocket
if (this.shouldReconnect) { if (this.shouldReconnect) {
console.log(`Attempting to reconnect...`) console.log(`Attempting to reconnect...`)
setTimeout(() => this.subscribeToEvents(), 1000) setTimeout(() => this.subscribeToEvents(), 1000)
} }
// Queue up health check
this.queue.add(() => this.healthz())
} }
resolve() resolve()