Merge pull request #3960 from janhq/fix/dangling-process-on-reset

chore: clean dangling process on exit and relaunch
This commit is contained in:
Louis 2024-11-06 13:39:10 +07:00 committed by GitHub
commit d0eb91fcd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -50,12 +50,18 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
// Run the process watchdog
const systemInfo = await systemInformation()
await this.clean()
await executeOnMain(NODE, 'run', systemInfo)
this.queue.add(() => this.healthz())
window.addEventListener('beforeunload', () => {
this.clean()
})
}
onUnload(): void {
this.clean()
executeOnMain(NODE, 'dispose')
super.onUnload()
}
@ -132,6 +138,20 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
})
.then(() => {})
}
/**
* Clean cortex processes
* @returns
*/
clean(): Promise<any> {
return ky
.delete(`${CORTEX_API_URL}/processmanager/destroy`, {
timeout: 2000, // maximum 2 seconds
})
.catch(() => {
// Do nothing
})
}
}
/// Legacy