소스 검색

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 년 전
부모
커밋
63c763685f
2개의 변경된 파일11개의 추가작업 그리고 1개의 파일을 삭제
  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()
 	}