Skip to content

Commit

Permalink
when app is running, server restarts when it exits or disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
Eva Ho committed Jul 10, 2023
1 parent 0859d50 commit 407a5ca
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const ollama = path.join(process.resourcesPath, 'ollama')

function server() {
const binary = app.isPackaged
? path.join(process.resourcesPath, 'ollama')
: path.resolve(process.cwd(), '..', 'ollama')
? path.join(process.resourcesPath, 'ollama')
: path.resolve(process.cwd(), '..', 'ollama')

console.log(`Starting server`)
const proc = spawn(binary, ['serve'])
Expand All @@ -52,11 +52,22 @@ function server() {
console.error(`server: ${data}`)
})

proc.on('exit', () => {
console.log('Restarting...');
server();
})

proc.on('disconnect', () => {
console.log('Restarting...');
server();
})

process.on('exit', () => {
proc.kill()
})
}


function installCLI() {
const symlinkPath = '/usr/local/bin/ollama'

Expand Down

0 comments on commit 407a5ca

Please sign in to comment.