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
3d0a9b47
Commit
3d0a9b47
authored
Jul 11, 2023
by
Jeffrey Morgan
Browse files
log to console as well as file
parent
7226980f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
21 deletions
+18
-21
app/src/index.ts
app/src/index.ts
+18
-21
No files found.
app/src/index.ts
View file @
3d0a9b47
...
@@ -13,18 +13,16 @@ require('@electron/remote/main').initialize()
...
@@ -13,18 +13,16 @@ require('@electron/remote/main').initialize()
const
store
=
new
Store
()
const
store
=
new
Store
()
let
tray
:
Tray
|
null
=
null
let
tray
:
Tray
|
null
=
null
const
logFile
=
new
winston
.
transports
.
File
({
const
logger
=
winston
.
createLogger
({
filename
:
path
.
join
(
app
.
getPath
(
'
home
'
),
'
.ollama
'
,
'
logs
'
,
'
server.log
'
),
transports
:
[
maxsize
:
1024
*
1024
*
20
,
new
winston
.
transports
.
Console
(),
maxFiles
:
5
,
new
winston
.
transports
.
File
({
});
filename
:
path
.
join
(
app
.
getPath
(
'
home
'
),
'
.ollama
'
,
'
logs
'
,
'
server.log
'
),
maxsize
:
1024
*
1024
*
20
,
const
logger
=
winston
.
createLogger
({
maxFiles
:
5
,
transports
:
[
logFile
],
}),
format
:
winston
.
format
.
combine
(
],
winston
.
format
.
timestamp
(),
format
:
winston
.
format
.
printf
(
info
=>
`
${
info
.
message
}
`
),
winston
.
format
.
printf
(
info
=>
`
${
info
.
timestamp
}
${
info
.
level
}
:
${
info
.
message
}
`
)
)
})
})
const
SingleInstanceLock
=
app
.
requestSingleInstanceLock
()
const
SingleInstanceLock
=
app
.
requestSingleInstanceLock
()
...
@@ -56,25 +54,25 @@ const ollama = path.join(process.resourcesPath, 'ollama')
...
@@ -56,25 +54,25 @@ const ollama = path.join(process.resourcesPath, 'ollama')
function
server
()
{
function
server
()
{
const
binary
=
app
.
isPackaged
const
binary
=
app
.
isPackaged
?
path
.
join
(
process
.
resourcesPath
,
'
ollama
'
)
?
path
.
join
(
process
.
resourcesPath
,
'
ollama
'
)
:
path
.
resolve
(
process
.
cwd
(),
'
..
'
,
'
ollama
'
)
:
path
.
resolve
(
process
.
cwd
(),
'
..
'
,
'
ollama
'
)
const
proc
=
spawn
(
binary
,
[
'
serve
'
])
const
proc
=
spawn
(
binary
,
[
'
serve
'
]
,
{
cwd
:
path
.
dirname
(
binary
)
}
)
proc
.
stdout
.
on
(
'
data
'
,
data
=>
{
proc
.
stdout
.
on
(
'
data
'
,
data
=>
{
logger
.
info
(
`server:
${
data
.
toString
()}
`
)
logger
.
info
(
`server:
${
data
.
toString
()}
`
)
})
})
proc
.
stderr
.
on
(
'
data
'
,
data
=>
{
proc
.
stderr
.
on
(
'
data
'
,
data
=>
{
logger
.
error
(
`server:
${
data
.
toString
()}
`
)
logger
.
info
(
`server:
${
data
.
toString
()}
`
)
})
})
proc
.
on
(
'
exit
'
,
()
=>
{
proc
.
on
(
'
exit
'
,
()
=>
{
logger
.
info
(
'
Restarting the server...
'
)
;
logger
.
info
(
'
Restarting the server...
'
)
server
()
;
server
()
})
})
proc
.
on
(
'
disconnect
'
,
()
=>
{
proc
.
on
(
'
disconnect
'
,
()
=>
{
logger
.
info
(
'
Server disconnected. Reconnecting...
'
)
;
logger
.
info
(
'
Server disconnected. Reconnecting...
'
)
server
()
;
server
()
})
})
process
.
on
(
'
exit
'
,
()
=>
{
process
.
on
(
'
exit
'
,
()
=>
{
...
@@ -82,7 +80,6 @@ function server() {
...
@@ -82,7 +80,6 @@ function server() {
})
})
}
}
function
installCLI
()
{
function
installCLI
()
{
const
symlinkPath
=
'
/usr/local/bin/ollama
'
const
symlinkPath
=
'
/usr/local/bin/ollama
'
...
...
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