Sfoglia il codice sorgente

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.

Mark Ward 1 anno fa
parent
commit
63c763685f
2 ha cambiato i file con 11 aggiunte e 1 eliminazioni
  1. 6 1
      llm/server.go
  2. 5 0
      server/sched.go

+ 6 - 1
llm/server.go

@@ -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

+ 5 - 0
server/sched.go

@@ -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()
 	}