mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-20 10:35:01 +00:00
feat: backend monitor shutdown endpoint, process based (#938)
This PR adds a new endpoint to the backend monitor section `/backend/shutdown` which terminates the grpc process for the related model.
This commit is contained in:
parent
901f0709c5
commit
10b0e13882
3 changed files with 51 additions and 19 deletions
|
@ -128,6 +128,16 @@ func (ml *ModelLoader) LoadModel(modelName string, loader func(string, string) (
|
|||
return model, nil
|
||||
}
|
||||
|
||||
func (ml *ModelLoader) ShutdownModel(modelName string) error {
|
||||
ml.mu.Lock()
|
||||
defer ml.mu.Unlock()
|
||||
if _, ok := ml.models[modelName]; !ok {
|
||||
return fmt.Errorf("model %s not found", modelName)
|
||||
}
|
||||
|
||||
return ml.deleteProcess(modelName)
|
||||
}
|
||||
|
||||
func (ml *ModelLoader) CheckIsLoaded(s string) *grpc.Client {
|
||||
if m, ok := ml.models[s]; ok {
|
||||
log.Debug().Msgf("Model already loaded in memory: %s", s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue