mirror of
https://github.com/mudler/LocalAI.git
synced 2025-02-20 09:26:15 +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
@ -376,7 +376,9 @@ func (ml *ModelLoader) grpcModel(backend string, o *Options) func(string, string
|
||||
|
||||
if !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")
|
||||
}
|
||||
|
||||
@ -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)
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ func (ml *ModelLoader) LoadModel(modelID, modelName string, loader func(string,
|
||||
defer ml.mu.Unlock()
|
||||
model, err := loader(modelID, modelName, modelFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to load model with internal loader: %s", err)
|
||||
}
|
||||
|
||||
if model == nil {
|
||||
|
@ -18,14 +18,18 @@ import (
|
||||
func (ml *ModelLoader) deleteProcess(s string) error {
|
||||
defer delete(ml.models, s)
|
||||
|
||||
log.Debug().Msgf("Deleting process %s", s)
|
||||
|
||||
m, exists := ml.models[s]
|
||||
if !exists {
|
||||
log.Error().Msgf("Model does not exist %s", s)
|
||||
// Nothing to do
|
||||
return nil
|
||||
}
|
||||
|
||||
process := m.Process()
|
||||
if process == nil {
|
||||
log.Error().Msgf("No process for %s", s)
|
||||
// Nothing to do as there is no process
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user