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:
Ettore Di Giacinto 2024-10-05 10:41:35 +02:00 committed by GitHub
parent 905473c739
commit e28e80857b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -157,6 +157,11 @@ func (ml *ModelLoader) ShutdownModel(modelName string) error {
}
time.Sleep(dur)
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)