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
3ae2f441
Commit
3ae2f441
authored
May 09, 2024
by
Daniel Hiltgen
Browse files
Fix race in shutdown logic
Ensure the runners are terminated
parent
83d6d46e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
5 deletions
+13
-5
server/routes.go
server/routes.go
+13
-5
No files found.
server/routes.go
View file @
3ae2f441
...
...
@@ -1036,7 +1036,8 @@ func Serve(ln net.Listener) error {
}
ctx
,
done
:=
context
.
WithCancel
(
context
.
Background
())
sched
:=
InitScheduler
(
ctx
)
schedCtx
,
schedDone
:=
context
.
WithCancel
(
ctx
)
sched
:=
InitScheduler
(
schedCtx
)
s
:=
&
Server
{
addr
:
ln
.
Addr
(),
sched
:
sched
}
r
:=
s
.
GenerateRoutes
()
...
...
@@ -1051,24 +1052,31 @@ func Serve(ln net.Listener) error {
go
func
()
{
<-
signals
srvr
.
Close
()
d
one
()
schedD
one
()
sched
.
unloadAllRunners
()
gpu
.
Cleanup
()
os
.
Exit
(
0
)
done
(
)
}()
if
err
:=
llm
.
Init
();
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to initialize llm library %w"
,
err
)
}
s
.
sched
.
Run
(
c
tx
)
s
.
sched
.
Run
(
schedC
tx
)
// At startup we retrieve GPU information so we can get log messages before loading a model
// This will log warnings to the log in case we have problems with detected GPUs
gpus
:=
gpu
.
GetGPUInfo
()
gpus
.
LogDetails
()
return
srvr
.
Serve
(
ln
)
err
=
srvr
.
Serve
(
ln
)
// If server is closed from the signal handler, wait for the ctx to be done
// otherwise error out quickly
if
!
errors
.
Is
(
err
,
http
.
ErrServerClosed
)
{
return
err
}
<-
ctx
.
Done
()
return
err
}
func
waitForStream
(
c
*
gin
.
Context
,
ch
chan
interface
{})
{
...
...
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