mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
fix(initializer): correctly reap dangling processes (#3717)
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
e5586e8781
commit
4686877c6d
3 changed files with 14 additions and 4 deletions
|
@ -376,7 +376,9 @@ func (ml *ModelLoader) grpcModel(backend string, o *Options) func(string, string
|
||||||
|
|
||||||
if !ready {
|
if !ready {
|
||||||
log.Debug().Msgf("GRPC Service NOT ready")
|
log.Debug().Msgf("GRPC Service NOT ready")
|
||||||
ml.deleteProcess(o.model)
|
if process := client.Process(); process != nil {
|
||||||
|
process.Stop()
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("grpc service not ready")
|
return nil, fmt.Errorf("grpc service not ready")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,11 +390,15 @@ func (ml *ModelLoader) grpcModel(backend string, o *Options) func(string, string
|
||||||
|
|
||||||
res, err := client.GRPC(o.parallelRequests, ml.wd).LoadModel(o.context, &options)
|
res, err := client.GRPC(o.parallelRequests, ml.wd).LoadModel(o.context, &options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ml.deleteProcess(o.model)
|
if process := client.Process(); process != nil {
|
||||||
|
process.Stop()
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("could not load model: %w", err)
|
return nil, fmt.Errorf("could not load model: %w", err)
|
||||||
}
|
}
|
||||||
if !res.Success {
|
if !res.Success {
|
||||||
ml.deleteProcess(o.model)
|
if process := client.Process(); process != nil {
|
||||||
|
process.Stop()
|
||||||
|
}
|
||||||
return nil, fmt.Errorf("could not load model (no success): %s", res.Message)
|
return nil, fmt.Errorf("could not load model (no success): %s", res.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ func (ml *ModelLoader) LoadModel(modelID, modelName string, loader func(string,
|
||||||
defer ml.mu.Unlock()
|
defer ml.mu.Unlock()
|
||||||
model, err := loader(modelID, modelName, modelFile)
|
model, err := loader(modelID, modelName, modelFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to load model with internal loader: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if model == nil {
|
if model == nil {
|
||||||
|
|
|
@ -18,14 +18,18 @@ import (
|
||||||
func (ml *ModelLoader) deleteProcess(s string) error {
|
func (ml *ModelLoader) deleteProcess(s string) error {
|
||||||
defer delete(ml.models, s)
|
defer delete(ml.models, s)
|
||||||
|
|
||||||
|
log.Debug().Msgf("Deleting process %s", s)
|
||||||
|
|
||||||
m, exists := ml.models[s]
|
m, exists := ml.models[s]
|
||||||
if !exists {
|
if !exists {
|
||||||
|
log.Error().Msgf("Model does not exist %s", s)
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
process := m.Process()
|
process := m.Process()
|
||||||
if process == nil {
|
if process == nil {
|
||||||
|
log.Error().Msgf("No process for %s", s)
|
||||||
// Nothing to do as there is no process
|
// Nothing to do as there is no process
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue