The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(build-llama): --check ends the server it started, not only its subshell
purple8e4836e5eadb
diff --git a/scripts/build-llama.sh b/scripts/build-llama.shindex 19654072..705eef73 100755--- a/scripts/build-llama.sh+++ b/scripts/build-llama.sh@@ -598,7 +598,10 @@ check_binary() {( cd "$run_dir" && "$bin" --version >/dev/null 2>&1 ) || die "$bin --version failed (run from $run_dir, LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-unset})"local port=8129log "boot check: $bin on 127.0.0.1:$port, cwd=$run_dir (no model, router mode, /health only)"- ( cd "$run_dir" && "$bin" --host 127.0.0.1 --port "$port" >/dev/null 2>&1 ) &+ # exec: $! has to be the server itself. Without it $! was the subshell, the+ # kill below ended only that, and a check that failed (E1: the 9 s Metal+ # first start) left a llama-server holding port 8129 behind.+ ( cd "$run_dir" && exec "$bin" --host 127.0.0.1 --port "$port" >/dev/null 2>&1 ) &local pid=$!trap 'kill "$pid" 2>/dev/null || true' EXITlocal ok=""@@ -607,7 +610,8 @@ check_binary() {# libraries ... in 9.314 sec"; later starts come out of the system's shader# cache in 0.3 s). The 9 s this loop used to allow is exactly that first# start, so it waits up to 60 s now.- for _ in $(seq 1 200); do+ # BUILD_LLAMA_CHECK_TRIES only for build-llama-script.test.ts.+ for _ in $(seq 1 "${BUILD_LLAMA_CHECK_TRIES:-200}"); doif curl -fsS "http://127.0.0.1:$port/health" >/dev/null 2>&1; then ok=1; break; fisleep 0.3donediff --git a/src/api/__tests__/build-llama-script.test.ts b/src/api/__tests__/build-llama-script.test.tsindex cd3df957..67cb2bd6 100644--- a/src/api/__tests__/build-llama-script.test.ts+++ b/src/api/__tests__/build-llama-script.test.ts@@ -504,3 +504,31 @@ cmake() {expect(existsSync(join(r.repoRoot, 'src-tauri', 'bin', 'lu-llama-cvector-generator-aarch64-apple-darwin'))).toBe(true)})})++describe('build-llama.sh --check: a failed boot leaves no server behind (E1)', { timeout: 30_000 }, () => {+ it('kills the server itself, not only the subshell that started it', () => {+ if (process.platform === 'win32') return+ const root = mkdtempSync(join(tmpdir(), 'bl-check-'))+ try {+ const triple = runScript('host_triple').out+ const bin = join(root, 'src-tauri', 'bin')+ execFileSync('mkdir', ['-p', bin])+ const pidFile = join(root, 'server.pid')+ // A server that never answers /health: it only records its PID and waits.+ const fake = join(bin, `lu-llama-server-${triple}`)+ writeFileSync(fake, `#!/bin/sh\n[ "$1" = "--version" ] && exit 0\necho $$ > '${pidFile}'\nexec sleep 30\n`, { mode: 0o755 })+ const r = runScript('check_binary', { BUILD_LLAMA_REPO_ROOT: root, BUILD_LLAMA_CHECK_TRIES: '3' })+ expect(r.code).not.toBe(0)+ expect(r.out).toMatch(/health endpoint never came up/)+ const pid = Number(readFileSync(pidFile, 'utf8').trim())+ let alive = true+ for (let i = 0; i < 20 && alive; i++) {+ try { process.kill(pid, 0); execFileSync('sleep', ['0.1']) } catch { alive = false }+ }+ if (alive) process.kill(pid, 'SIGKILL')+ expect(alive).toBe(false)+ } finally {+ rmSync(root, { recursive: true, force: true })+ }+ })+})