log when the waiting for the process to stop to help debug when other tasks execute during this wait.

expire timer clear the timer reference because it will not be reused.
close will clean up expireTimer if calling code has not already done this.
This commit is contained in:
Mark Ward 2024-04-29 18:06:56 +00:00
parent 34a4a94f13
commit 63c763685f
2 changed files with 11 additions and 1 deletions

View file

@ -902,7 +902,12 @@ func (s *llmServer) Close() error {
if err := s.cmd.Process.Kill(); err != nil {
return err
}
return s.cmd.Wait()
if err := s.cmd.Wait(); err != nil {
return err
}
slog.Debug("llama server stopped")
}
return nil

View file

@ -250,6 +250,7 @@ func (s *Scheduler) processCompleted(ctx context.Context) {
defer runner.refMu.Unlock()
if runner.expireTimer != nil {
runner.expireTimer.Stop()
runner.expireTimer = nil
}
s.expiredCh <- runner
})
@ -430,6 +431,10 @@ type runnerRef struct {
// The refMu must already be held when calling unload
func (runner *runnerRef) unload() {
if runner.expireTimer != nil {
runner.expireTimer.Stop()
runner.expireTimer = nil
}
if runner.llama != nil {
runner.llama.Close()
}