Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
mlxrunner: wait for a killed runner to exit before the scheduler loads the next model
Jesse Grossf09d55d0e247
diff --git a/x/mlxrunner/client.go b/x/mlxrunner/client.goindex 728ba654d..5bdfb56e8 100644--- a/x/mlxrunner/client.go+++ b/x/mlxrunner/client.go@@ -42,6 +42,7 @@ type Client struct {status *llm.StatusWritermu sync.Mutexcmd *exec.Cmd+ closed bool}// NewClient prepares a new MLX runner client for LLM models.@@ -141,15 +142,11 @@ func (c *Client) Close() error {c.mu.Lock()defer c.mu.Unlock()+ c.closed = trueif c.cmd != nil && c.cmd.Process != nil {slog.Info("stopping mlx runner subprocess", "pid", c.cmd.Process.Pid)- c.cmd.Process.Signal(os.Interrupt)-- select {- case <-c.done:- case <-time.After(5 * time.Second):- c.cmd.Process.Kill()- }+ c.cmd.Process.Kill()+ <-c.donec.cmd = nil}return nil@@ -405,19 +402,24 @@ func (c *Client) Load(ctx context.Context, systemInfo ml.SystemInfo, gpus []ml.D}}- c.cmd = cmd-status := llm.NewStatusWriter(os.Stderr)- c.status = status// os/exec serializes Write calls when shared, which keeps the status writer// from seeing concurrent stdout/stderr fragments.cmd.Stdout = statuscmd.Stderr = status+ c.mu.Lock()+ defer c.mu.Unlock()+ if c.closed {+ return nil, errors.New("mlx runner client is closed")+ }++ c.status = statusslog.Info("starting mlx runner subprocess", "model", c.modelName, "port", c.port)if err := cmd.Start(); err != nil {return nil, fmt.Errorf("failed to start mlx runner: %w", err)}+ c.cmd = cmd// Reap subprocess when it exitsgo func() {