mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-28 22:44:59 +00:00
feat(shutdown): allow force shutdown of backends (#3733)
We default to a soft kill, however, we might want to force killing backends after a while to avoid hanging requests (which may hallucinate indefinetly) Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
905473c739
commit
e28e80857b
1 changed files with 5 additions and 0 deletions
|
@ -157,6 +157,11 @@ func (ml *ModelLoader) ShutdownModel(modelName string) error {
|
||||||
}
|
}
|
||||||
time.Sleep(dur)
|
time.Sleep(dur)
|
||||||
retries++
|
retries++
|
||||||
|
|
||||||
|
if retries > 10 && os.Getenv("LOCALAI_FORCE_BACKEND_SHUTDOWN") == "true" {
|
||||||
|
log.Warn().Msgf("Model %s is still busy after %d retries. Forcing shutdown.", modelName, retries)
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ml.deleteProcess(modelName)
|
return ml.deleteProcess(modelName)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue