Skip to content

Commit

Permalink
feat(shutdown): allow force shutdown of backends (#3733)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mudler authored Oct 5, 2024
1 parent 905473c commit e28e808
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/model/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e28e808

Please sign in to comment.