chore: clean dangling process on exit and relaunch
This commit is contained in:
parent
24b7d64efc
commit
56e35df84d
@ -50,12 +50,18 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
|||||||
|
|
||||||
// Run the process watchdog
|
// Run the process watchdog
|
||||||
const systemInfo = await systemInformation()
|
const systemInfo = await systemInformation()
|
||||||
|
await this.clean()
|
||||||
await executeOnMain(NODE, 'run', systemInfo)
|
await executeOnMain(NODE, 'run', systemInfo)
|
||||||
|
|
||||||
this.queue.add(() => this.healthz())
|
this.queue.add(() => this.healthz())
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', () => {
|
||||||
|
this.clean()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onUnload(): void {
|
onUnload(): void {
|
||||||
|
this.clean()
|
||||||
executeOnMain(NODE, 'dispose')
|
executeOnMain(NODE, 'dispose')
|
||||||
super.onUnload()
|
super.onUnload()
|
||||||
}
|
}
|
||||||
@ -132,6 +138,20 @@ export default class JanInferenceCortexExtension extends LocalOAIEngine {
|
|||||||
})
|
})
|
||||||
.then(() => {})
|
.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
|
/// Legacy
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user