From 9e639100cff88106efc72e96fb43c35ba466be53 Mon Sep 17 00:00:00 2001 From: jon Date: Wed, 22 Jul 2026 11:37:48 -0500 Subject: [PATCH] Sync from upstream: ncp stop no longer misreports Ollama Co-Authored-By: Claude Opus 4.8 --- management/ncp.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/management/ncp.py b/management/ncp.py index 662e340..a61840b 100644 --- a/management/ncp.py +++ b/management/ncp.py @@ -199,11 +199,14 @@ def wait_for_port_close(port: int, timeout: int = 15) -> bool: return False -def kill_matching(patterns, force=False) -> None: +def kill_matching(patterns, force=False) -> int: """The pkill -f sweep: catches reparented grandchildren (npm -> sh -> node - vite), uvicorn --reload workers, and instances started outside this CLI.""" + vite), uvicorn --reload workers, and instances started outside this CLI. + Returns how many processes it signalled, so callers can stay quiet when + there was nothing to kill.""" ps = _psutil() me = os.getpid() + hit = 0 for proc in ps.process_iter(["pid", "cmdline"]): if proc.info["pid"] == me: continue @@ -211,8 +214,10 @@ def kill_matching(patterns, force=False) -> None: if any(p in cmd for p in patterns): try: proc.kill() if force else proc.terminate() + hit += 1 except Exception: pass + return hit def kill_port(port: int) -> bool: @@ -292,8 +297,11 @@ def stop_ollama() -> None: return except Exception: pass - kill_matching(["ollama serve"]) - print("NEXUS OLLAMA STOPPED (direct)") + # Silent when there was nothing to stop - the bash version only announced a + # direct kill if `pgrep ollama serve` actually matched, and claiming to have + # stopped a service that was never running is worse than saying nothing. + if kill_matching(["ollama serve"]): + print("NEXUS OLLAMA STOPPED (direct)") # -- commands ------------------------------------------------------------------