Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
fix(local-installation): stop node-services before recreating the stack
shoudi zhengc8384aac5ebe
diff --git a/docs/self-hosting.md b/docs/self-hosting.mdindex 3c23d84f..3384d27a 100644--- a/docs/self-hosting.md+++ b/docs/self-hosting.md@@ -24,9 +24,11 @@ Open <http://localhost:3000> and sign in. The app then shows the commands thatconnect your computer, and it opens once Claude Code, Codex or Pi is installedand signed in there.-To serve other computers on your network, set these in `.env` and run+To serve other computers on your network, set these in `.env`, run+`docker compose stop node-services`, then run`docker compose up --detach --wait` again, replacing `192.168.1.10` with this-computer's address. Browsers and Computers then reach everything through port 3000.+computer's address. Stopping node-services first while TeamHub is still up+puts replies in progress back in the queue instead of failing them. Browsers and Computers then reach everything through port 3000.```bashWEB_BIND_ADDRESS=0.0.0.0@@ -42,11 +44,11 @@ your machine against a PostgreSQL you provide; see## Troubleshooting-| Problem | What to try |-| -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| The app does not open | `docker compose ps`, then `docker compose logs <service>` |-| The computer shows offline, or agents never answer | On that computer, `linger-computer daemon status` and `linger-computer doctor`; read `linger-computer daemon logs`, then try `linger-computer daemon restart` |-| "No runtime is ready yet" | `linger-computer runtime check` lists what to install or sign in to; `linger-computer runtime check codex --live` also waits for a real model reply |-| Other computers cannot connect | Set the four variables under [Build from source](#build-from-source) and run `docker compose up --detach --wait` again |-| The microphone is blocked | Browsers allow it only on `localhost` or HTTPS; put an HTTPS proxy in front of port 3000 |-| `pnpm dev` cannot reach the database | `pnpm dev` starts no containers: run `docker compose up --detach --wait postgres` first, then check every service with `pnpm dev:check` |+| Problem | What to try |+| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| The app does not open | `docker compose ps`, then `docker compose logs <service>` |+| The computer shows offline, or agents never answer | On that computer, `linger-computer daemon status` and `linger-computer doctor`; read `linger-computer daemon logs`, then try `linger-computer daemon restart` |+| "No runtime is ready yet" | `linger-computer runtime check` lists what to install or sign in to; `linger-computer runtime check codex --live` also waits for a real model reply |+| Other computers cannot connect | Set the four variables under [Build from source](#build-from-source) and run `docker compose stop node-services`, then `docker compose up --detach --wait` again |+| The microphone is blocked | Browsers allow it only on `localhost` or HTTPS; put an HTTPS proxy in front of port 3000 |+| `pnpm dev` cannot reach the database | `pnpm dev` starts no containers: run `docker compose up --detach --wait postgres` first, then check every service with `pnpm dev:check` |diff --git a/package.json b/package.jsonindex 2643f886..44670dad 100644--- a/package.json+++ b/package.json@@ -17,7 +17,7 @@"dev:livekit": "node scripts/with-local-env.mjs -- node --import tsx scripts/dev-livekit.ts","dev:node-services": "node scripts/with-local-env.mjs -- pnpm --filter @linger/node-services start","env:inventory:check": "node --import tsx scripts/check-env-inventory.ts",- "stack:up": "node scripts/with-local-env.mjs --optional -- sh -c 'for service in teamhub-migrate teamhub node-services web; do docker compose build \"$service\" || exit; done; docker compose up --detach --wait'",+ "stack:up": "node scripts/with-local-env.mjs --optional -- sh -c 'for service in teamhub-migrate teamhub node-services web; do docker compose build \"$service\" || exit; done; docker compose stop node-services && docker compose up --detach --wait'","stack:logs": "node scripts/with-local-env.mjs --optional -- docker compose logs --follow","stack:down": "node scripts/with-local-env.mjs --optional -- docker compose down","infra:up": "docker compose up -d postgres",diff --git a/packages/local-installation/AGENTS.md b/packages/local-installation/AGENTS.mdindex e84a1137..69c9a77b 100644--- a/packages/local-installation/AGENTS.md+++ b/packages/local-installation/AGENTS.md@@ -22,6 +22,9 @@ package's `.env` is not read. In a release, a voice key turns on the Composethe key pair and media ports in the instance's `livekit.env`; the gatewayforwards `/rtc` to it. `compose up` recreates what a changed `user.env`touches; a native process restarts when its generated environment changes.+Every update or recreate path stops node-services on its own, right before+the recreate and while TeamHub is still up, so its graceful shutdown requeues+in-flight Agent Runs instead of failing them.Move a freshly downloaded or unpacked file or folder into place with`renameRetrying` from `fs-retry.ts`: on Windows antivirus and indexing holddiff --git a/packages/local-installation/src/native-source-flow.test.ts b/packages/local-installation/src/native-source-flow.test.tsindex 0affe075..f1e4e044 100644--- a/packages/local-installation/src/native-source-flow.test.ts+++ b/packages/local-installation/src/native-source-flow.test.ts@@ -316,6 +316,63 @@ test("failed preparation never stops services that were already running", asyncexpect(f.running.has("postgres")).toBe(true);});+test("a running node-services stops before TeamHub restarts", async () => {+ const f = await fixture();+ for (const name of ["teamhub", "node-services", "web"]) f.running.add(name);+ vi.mocked(prepareRuntime).mockResolvedValue({+ code: 0,+ state: "ready",+ message: "ready",+ });+ await installNativeSource({+ ...f,+ name: "native-flow",+ setupChoice: "pi",+ signal: new AbortController().signal,+ onEvent: () => {},+ });+ expect(+ vi.mocked(stopNativeProcess).mock.calls.map((call) => call[1]),+ ).toEqual(["node-services"]);+ const teamHubStart = vi+ .mocked(startNativeProcess)+ .mock.calls.findIndex(([options]) => options.name === "teamhub");+ expect(vi.mocked(stopNativeProcess).mock.invocationCallOrder[0]).toBeLessThan(+ vi.mocked(startNativeProcess).mock.invocationCallOrder[teamHubStart]!,+ );+ expect(f.running.has("node-services")).toBe(true);+});++test("a failure after the restart stops the node-services this run started", async () => {+ const f = await fixture();+ for (const name of ["postgres", "teamhub", "node-services"])+ f.running.add(name);+ vi.mocked(prepareRuntime).mockResolvedValue({+ code: 0,+ state: "ready",+ message: "ready",+ });+ vi.mocked(startNativeProcess).mockImplementation(async (options) => {+ if (options.name === "web") throw new Error("web failed");+ f.running.add(options.name);+ return { running: true, pid: 100 };+ });+ const result = await installNativeSource({+ ...f,+ name: "native-flow",+ setupChoice: "pi",+ signal: new AbortController().signal,+ onEvent: () => {},+ });+ expect(result.code).toBe(1);+ // The first stop hands in-flight Runs back; the rollback stops the+ // processes this run started, and leaves the earlier TeamHub alone.+ expect(+ vi.mocked(stopNativeProcess).mock.calls.map((call) => call[1]),+ ).toEqual(["node-services", "web", "node-services"]);+ expect(f.running.has("teamhub")).toBe(true);+});+test("stops native business services even if owned gateway shutdown reports a failure", async () => {const f = await fixture();const { prepareNativeConfiguration } = await import("./native-source.js");diff --git a/packages/local-installation/src/native-source.ts b/packages/local-installation/src/native-source.tsindex f2caaa49..e30e7285 100644--- a/packages/local-installation/src/native-source.ts+++ b/packages/local-installation/src/native-source.ts@@ -789,6 +789,11 @@ async function runNativeSource((await inspectNativeProcess(current.root, "livekit")).running)await stopNativeProcess(current.root, "livekit");+ // Stop the Agent Service while TeamHub is still up so its graceful+ // shutdown can requeue in-flight Agent Runs before TeamHub restarts.+ // The loop below then sees it stopped and records it as started here.+ if ((await inspectNativeProcess(current.root, "node-services")).running)+ await stopNativeProcess(current.root, "node-services");for (const name of ["teamhub", "node-services", "web"] as const) {const running = (await inspectNativeProcess(current.root, name)).running;