start server in both dev and when packaged

This commit is contained in:
Jeffrey Morgan 2023-07-10 13:46:31 -07:00
parent 2d49197b3b
commit 66bbf05918
2 changed files with 33 additions and 50 deletions

View file

@ -38,27 +38,10 @@ if (require('electron-squirrel-startup')) {
const ollama = path.join(process.resourcesPath, 'ollama')
// if the app is packaged then run the server
if (app.isPackaged) {
// Start the executable
console.log(`Starting server`)
const proc = spawn(ollama, ['serve'])
proc.stdout.on('data', data => {
console.log(`server: ${data}`)
})
proc.stderr.on('data', data => {
console.error(`server: ${data}`)
})
process.on('exit', () => {
proc.kill()
})
}
function server() {
const binary = app.isPackaged
? path.join(process.resourcesPath, 'ollama')
: path.resolve(__dirname, '..', '..', 'ollama')
: path.resolve(process.cwd(), '..', 'ollama')
console.log(`Starting server`)
const proc = spawn(binary, ['serve'])
@ -118,6 +101,7 @@ app.on('ready', () => {
app.setLoginItemSettings({ openAtLogin: app.getLoginItemSettings().openAtLogin })
}
if (app.isPackaged) {
if (!app.isInApplicationsFolder()) {
const chosen = dialog.showMessageBoxSync({
type: 'question',
@ -149,13 +133,14 @@ app.on('ready', () => {
}
}
}
installCLI()
}
}
createSystemtray()
if (app.isPackaged) {
installCLI()
}
server()
})
// Quit when all windows are closed, except on macOS. There, it's common

View file

@ -4,8 +4,6 @@ import Store from 'electron-store'
const store = new Store()
console.log(process.env)
export const analytics = new Analytics({ writeKey: process.env.TELEMETRY_WRITE_KEY || '<empty>' })
export function id(): string {