@@ -36,7 +36,6 @@ import (
3636)
3737
3838const LlamaFileVersion = "0.8.16"
39- const mockHarnessPID = "mock"
4039
4140type LLMHarness struct {
4241 Host string
@@ -146,45 +145,17 @@ func (harness *LLMHarness) Start(modelPath string, loraPaths []string) (err erro
146145 return nil
147146}
148147
149- func (harness * LLMHarness ) MarkMockRunning () error {
150- harnessPath := constants .HarnessPath (harness .ConfigHome )
151- pidFile := filepath .Join (harnessPath , constants .HarnessProcessFile )
152-
153- if err := os .MkdirAll (harnessPath , 0o755 ); err != nil {
154- return fmt .Errorf ("error creating directory %s: %w" , harnessPath , err )
155- }
156-
157- if err := os .WriteFile (pidFile , []byte (mockHarnessPID ), 0644 ); err != nil {
158- return fmt .Errorf ("error writing PID to file %s: %w" , pidFile , err )
159- }
160-
161- return nil
162- }
163-
164148func (harness * LLMHarness ) Stop () error {
165149 pidFile := filepath .Join (constants .HarnessPath (harness .ConfigHome ), constants .HarnessProcessFile )
166- pidData , err := os .ReadFile (pidFile )
150+
151+ pid , err := readPIDFromFile (pidFile )
167152 if os .IsNotExist (err ) {
168153 return fmt .Errorf ("no Running server found" )
169154 }
170155 if err != nil {
171156 return err
172157 }
173158
174- pidStr := strings .TrimSpace (string (pidData ))
175-
176- if pidStr == mockHarnessPID {
177- if err := os .Remove (pidFile ); err != nil {
178- return fmt .Errorf ("error removing PID file: %w" , err )
179- }
180- return nil
181- }
182-
183- pid , err := strconv .Atoi (pidStr )
184- if err != nil {
185- return fmt .Errorf ("invalid PID file contents: %w" , err )
186- }
187-
188159 // Check if the process is still running.
189160 if ! isProcessRunning (pid ) {
190161 return fmt .Errorf ("no running process found with PID %d" , pid )
0 commit comments