Skip to content

Commit

Permalink
chore: clean dangling process on exit and relaunch
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Nov 6, 2024
1 parent 24b7d64 commit 56e35df
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions extensions/inference-cortex-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56e35df

Please sign in to comment.