Skip to content

feat(install): prestart guard reclaims :11434 from Ollama squatters#10

Merged
sunrunnerfire merged 1 commit into
mainfrom
feat/launchagent-prestart-port-guard
May 31, 2026
Merged

feat(install): prestart guard reclaims :11434 from Ollama squatters#10
sunrunnerfire merged 1 commit into
mainfrom
feat/launchagent-prestart-port-guard

Conversation

@sunrunnerfire
Copy link
Copy Markdown
Contributor

Problem

Ollama.app auto-launches ollama serve, which grabs :11434 — quenchforge's canonical port. quenchforge's pre-bind check deliberately yields (exits 0) when the port is held, and the LaunchAgent's KeepAlive.SuccessfulExit=false then leaves the job dead. So during any quenchforge restart window, Ollama can win the port and quenchforge stays down until an operator hand-evicts it (launchctl bootout com.ollama.ollama + re-kickstart). This recurs on every login/restart.

Moving quenchforge off :11434 was considered and rejected: 111+ consumers (cerid-ai, contextplus, docs) assume the canonical Ollama-API port, and vacating it would let Ollama silently answer those clients with the wrong backend.

Fix

quenchforge install now writes a prestart guard to ~/.config/quenchforge/prestart-guard.sh and points the generated plist's ProgramArguments[0] at it. Before exec'ing quenchforge serve, the guard:

  1. boots out com.ollama.ollama (if its launchd job exists) so it can't respawn the serve child;
  2. evicts any non-quenchforge listener still on the port (matches lsof by command, never kills a running quenchforge/llama-server);
  3. execs quenchforge serve (launchd supervises quenchforge directly).

So quenchforge authoritatively reclaims the port on every (re)start and at login, with no manual step. It's a no-op when Ollama isn't installed and only ever targets the actual squatter.

Changes

  • cmd/quenchforge/prestart-guard.sh — the guard (embedded via //go:embed).
  • cmd/quenchforge/install.go — write the guard (0755) to ~/.config/quenchforge/ during install.
  • cmd/quenchforge/plist_template.plistProgramArguments[0] → guard; comments updated.
  • cmd/quenchforge/install_test.goTestInstall_WritesPlistAndPrestartGuard.
  • packaging/macos/README.md, CHANGELOG.md (Unreleased).

Build/vet/gofmt clean; bash -n on the guard passes. macOS-only path; install test skips on Linux.

quenchforge's pre-bind check yields (exits 0) when 11434 is already held,
and the LaunchAgent's KeepAlive.SuccessfulExit=false then leaves the job
dead — so anything that grabs the port during a restart window (classically
Ollama.app's auto-launched `ollama serve`) wins and quenchforge stays down
until hand-evicted.

`quenchforge install` now writes a prestart guard to
~/.config/quenchforge/prestart-guard.sh and points the generated plist's
ProgramArguments[0] at it. On every (re)start + at login the guard boots
out com.ollama.ollama, evicts any non-quenchforge listener on the port,
then execs `quenchforge serve` — so quenchforge authoritatively owns the
canonical Ollama-API port without ceding it or needing a manual eviction.

The guard only kills the actual squatter (never a running quenchforge /
llama-server) and is a no-op when Ollama isn't present. Covered by
TestInstall_WritesPlistAndPrestartGuard. Operators who intentionally run
Ollama can point ProgramArguments back at the bare binary.
@sunrunnerfire sunrunnerfire merged commit d0b4ef0 into main May 31, 2026
6 checks passed
@sunrunnerfire sunrunnerfire deleted the feat/launchagent-prestart-port-guard branch May 31, 2026 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant