mirror of
https://github.com/mudler/LocalAI.git
synced 2025-02-20 17:32:47 +00:00
fix(watchdog): use ShutdownModel instead of StopModel (#1882)
Fixes #1760
This commit is contained in:
parent
49cec7fd61
commit
bd25d8049c
@ -155,10 +155,10 @@ func (ml *ModelLoader) ShutdownModel(modelName string) error {
|
||||
ml.mu.Lock()
|
||||
defer ml.mu.Unlock()
|
||||
|
||||
return ml.StopModel(modelName)
|
||||
return ml.stopModel(modelName)
|
||||
}
|
||||
|
||||
func (ml *ModelLoader) StopModel(modelName string) error {
|
||||
func (ml *ModelLoader) stopModel(modelName string) error {
|
||||
defer ml.deleteProcess(modelName)
|
||||
if _, ok := ml.models[modelName]; !ok {
|
||||
return fmt.Errorf("model %s not found", modelName)
|
||||
|
@ -30,7 +30,7 @@ type WatchDog struct {
|
||||
}
|
||||
|
||||
type ProcessManager interface {
|
||||
StopModel(modelName string) error
|
||||
ShutdownModel(modelName string) error
|
||||
}
|
||||
|
||||
func NewWatchDog(pm ProcessManager, timeoutBusy, timeoutIdle time.Duration, busy, idle bool) *WatchDog {
|
||||
@ -112,9 +112,10 @@ func (wd *WatchDog) checkIdle() {
|
||||
log.Warn().Msgf("[WatchDog] Address %s is idle for too long, killing it", address)
|
||||
p, ok := wd.addressModelMap[address]
|
||||
if ok {
|
||||
if err := wd.pm.StopModel(p); err != nil {
|
||||
if err := wd.pm.ShutdownModel(p); err != nil {
|
||||
log.Error().Msgf("[watchdog] Error shutting down model %s: %v", p, err)
|
||||
}
|
||||
log.Debug().Msgf("[WatchDog] model shut down: %s", address)
|
||||
delete(wd.idleTime, address)
|
||||
delete(wd.addressModelMap, address)
|
||||
delete(wd.addressMap, address)
|
||||
@ -139,9 +140,10 @@ func (wd *WatchDog) checkBusy() {
|
||||
model, ok := wd.addressModelMap[address]
|
||||
if ok {
|
||||
log.Warn().Msgf("[WatchDog] Model %s is busy for too long, killing it", model)
|
||||
if err := wd.pm.StopModel(model); err != nil {
|
||||
if err := wd.pm.ShutdownModel(model); err != nil {
|
||||
log.Error().Msgf("[watchdog] Error shutting down model %s: %v", model, err)
|
||||
}
|
||||
log.Debug().Msgf("[WatchDog] model shut down: %s", address)
|
||||
delete(wd.timetable, address)
|
||||
delete(wd.addressModelMap, address)
|
||||
delete(wd.addressMap, address)
|
||||
@ -149,7 +151,6 @@ func (wd *WatchDog) checkBusy() {
|
||||
log.Warn().Msgf("[WatchDog] Address %s unresolvable", address)
|
||||
delete(wd.timetable, address)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user