Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
66bbf059
Commit
66bbf059
authored
Jul 10, 2023
by
Jeffrey Morgan
Browse files
start server in both dev and when packaged
parent
2d49197b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
51 deletions
+34
-51
app/src/index.ts
app/src/index.ts
+34
-49
app/src/telemetry.ts
app/src/telemetry.ts
+0
-2
No files found.
app/src/index.ts
View file @
66bbf059
...
...
@@ -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,44 +101,46 @@ app.on('ready', () => {
app
.
setLoginItemSettings
({
openAtLogin
:
app
.
getLoginItemSettings
().
openAtLogin
})
}
if
(
!
app
.
isInApplicationsFolder
())
{
const
chosen
=
dialog
.
showMessageBoxSync
({
type
:
'
question
'
,
buttons
:
[
'
Move to Applications
'
,
'
Do Not Move
'
],
message
:
'
Ollama works best when run from the Applications directory.
'
,
defaultId
:
0
,
cancelId
:
1
,
})
if
(
chosen
===
0
)
{
try
{
app
.
moveToApplicationsFolder
({
conflictHandler
:
conflictType
=>
{
if
(
conflictType
===
'
existsAndRunning
'
)
{
dialog
.
showMessageBoxSync
({
type
:
'
info
'
,
message
:
'
Cannot move to Applications directory
'
,
detail
:
'
Another version of Ollama is currently running from your Applications directory. Close it first and try again.
'
,
})
}
return
true
},
})
return
}
catch
(
e
)
{
console
.
error
(
'
Failed to move to applications folder
'
)
console
.
error
(
e
)
if
(
app
.
isPackaged
)
{
if
(
!
app
.
isInApplicationsFolder
())
{
const
chosen
=
dialog
.
showMessageBoxSync
({
type
:
'
question
'
,
buttons
:
[
'
Move to Applications
'
,
'
Do Not Move
'
],
message
:
'
Ollama works best when run from the Applications directory.
'
,
defaultId
:
0
,
cancelId
:
1
,
})
if
(
chosen
===
0
)
{
try
{
app
.
moveToApplicationsFolder
({
conflictHandler
:
conflictType
=>
{
if
(
conflictType
===
'
existsAndRunning
'
)
{
dialog
.
showMessageBoxSync
({
type
:
'
info
'
,
message
:
'
Cannot move to Applications directory
'
,
detail
:
'
Another version of Ollama is currently running from your Applications directory. Close it first and try again.
'
,
})
}
return
true
},
})
return
}
catch
(
e
)
{
console
.
error
(
'
Failed to move to applications folder
'
)
console
.
error
(
e
)
}
}
}
installCLI
()
}
}
createSystemtray
()
if
(
app
.
isPackaged
)
{
installCLI
()
}
server
()
})
// Quit when all windows are closed, except on macOS. There, it's common
...
...
app/src/telemetry.ts
View file @
66bbf059
...
...
@@ -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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment