Skip to content

Commit

Permalink
fix(watchdog): use ShutdownModel instead of StopModel (#1882)
Browse files Browse the repository at this point in the history
Fixes #1760
  • Loading branch information
mudler committed Mar 23, 2024
1 parent 49cec7f commit bd25d80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/model/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions pkg/model/watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -139,17 +140,17 @@ 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)
} else {
log.Warn().Msgf("[WatchDog] Address %s unresolvable", address)
delete(wd.timetable, address)
}

}
}
}

0 comments on commit bd25d80

Please sign in to comment.