Skip to content

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(install): inherit LiveKit config when changing RTC ports

Dongdong Chen605ac15a5203
diff --git a/README.md b/README.md
index e1027a5a..14ea77ea 100644
--- a/README.md
+++ b/README.md
@@ -208,9 +208,9 @@ approval, and connects `linger-computer` to your Linger server. Run
model setups.
If Compose ports are busy, the installer offers to select free ports. It saves
-LiveKit's port mappings and matching RTC configuration in
-`.local/compose.ports.yml` and enables the override through `.env`. Rerunning the
-installer reuses those ports.
+LiveKit's port mappings and matching RTC startup arguments in
+`.local/compose.ports.yml` and enables the override through `.env`. This requires
+Docker Compose 2.24.4 or later. Rerunning the installer reuses those ports.
## Learn more
diff --git a/scripts/install.test.ts b/scripts/install.test.ts
index fc96dfab..f358a7a5 100644
--- a/scripts/install.test.ts
+++ b/scripts/install.test.ts
@@ -760,6 +760,7 @@ describe("root install.sh", () => {
const homeDir = path.join(root, "home");
const xdgCache = path.join(root, "cache");
const dockerLogPath = path.join(root, "docker-calls.log");
+ const serverStartedPath = path.join(root, "server-started");
await mkdir(path.join(fakeRepo, "scripts/install"), { recursive: true });
await mkdir(path.join(fakeRepo, "scripts/installs"), { recursive: true });
await mkdir(path.join(fakeRepo, ".linger-runtime"), { recursive: true });
@@ -803,13 +804,16 @@ describe("root install.sh", () => {
set -eu
printf '%s\n' "$*" >> ${JSON.stringify(dockerLogPath)}
if [ "\${1:-}" = "compose" ] && [ "\${2:-}" = "version" ]; then
- printf 'Docker Compose version v2.40.2\n'
+ printf '2.24.4\n'
exit 0
fi
if [ "\${1:-}" = "compose" ] && [ "\${2:-}" = "ps" ]; then
printf '127.0.0.1:5432->5432/tcp\n'
exit 0
fi
+if [ "\${1:-}" = "compose" ] && [ "\${2:-}" = "up" ]; then
+ touch ${JSON.stringify(serverStartedPath)}
+fi
exit 0
`,
{ mode: 0o755 },
@@ -833,6 +837,7 @@ for a in "$@"; do
done
case "$url" in
"http://localhost:3001/install/linger-computer.sh")
+ if [ ! -f ${JSON.stringify(serverStartedPath)} ]; then exit 22; fi
body="# linger-computer-launcher-v2"
if [ -n "$out" ]; then printf '%s\n' "$body" > "$out"; else printf '%s\n' "$body"; fi
exit 0
@@ -876,9 +881,10 @@ esac
expect(updatedEnv).not.toContain("POSTGRES_PORT=5433");
const overridePath = path.join(fakeRepo, ".local/compose.ports.yml");
const override = await readFile(overridePath, "utf8");
- expect(override).toContain("tcp_port: 7883");
- expect(override).toContain("udp_port: 7884");
- expect(override).toContain("use_external_ip: false");
+ expect(override).toContain(
+ "entrypoint: /livekit-server --rtc.tcp_port 7883 --udp-port 7884",
+ );
+ expect(override).not.toContain("command:");
expect(override).toContain("ports: !override");
expect(override).toContain('"127.0.0.1:17881:7880"');
expect(override).toContain(
@@ -891,6 +897,7 @@ esac
const dockerCalls = await readFile(dockerLogPath, "utf8");
expect(dockerCalls).toContain("compose up --build --detach --wait");
+ await rm(serverStartedPath);
const repeated = await runInstallScript([], {
scriptPath: copiedInstallPath,
cwd: fakeRepo,
@@ -903,11 +910,35 @@ esac
input: ["1", "n", "n", "n"].join("\n") + "\n",
});
expect(repeated.code).toBe(0);
+ expect(repeated.stdout).toContain("Starting Linger with Docker Compose...");
expect(repeated.stdout).not.toContain("Port(s) already in use:");
expect(await readFile(path.join(fakeRepo, ".env"), "utf8")).toBe(
updatedEnv,
);
expect(await readFile(overridePath, "utf8")).toBe(override);
+
+ const dockerPath = path.join(fakeBin, "docker");
+ await writeFile(
+ dockerPath,
+ (await readFile(dockerPath, "utf8")).replace("2.24.4", "2.24.3"),
+ );
+ await rm(serverStartedPath);
+ const unsupported = await runInstallScript([], {
+ scriptPath: copiedInstallPath,
+ cwd: fakeRepo,
+ env: {
+ HOME: homeDir,
+ XDG_CACHE_HOME: xdgCache,
+ PATH: `${fakeBin}:/usr/local/bin:/usr/bin:/bin`,
+ LINGER_INSTALL_BUSY_PORTS: "7883/tcp",
+ },
+ input: ["1", "y"].join("\n") + "\n",
+ });
+ expect(unsupported.code).toBe(1);
+ expect(unsupported.stderr).toContain(
+ "requires Docker Compose 2.24.4 or later",
+ );
+ expect(await readFile(overridePath, "utf8")).toBe(override);
});
it("validates CLI flags, conflicting modes, and standalone menu outside repo", async () => {
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 13b2cf6f..897541ab 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -435,7 +435,7 @@ read_livekit_override_port() {
if [[ "$key" == "http" ]]; then
port="$(sed -nE 's/.*:([0-9]+):7880"[[:space:]]*$/\1/p' "$file")"
else
- port="$(sed -nE "s/^[[:space:]]*${key}:[[:space:]]*([0-9]+)[[:space:]]*$/\1/p" "$file")"
+ port="$(sed -nE "s/.*--${key}[[:space:]]+([0-9]+).*/\1/p" "$file")"
fi
fi
printf '%s\n' "${port:-$fallback}"
@@ -530,8 +530,8 @@ ensure_compose_ports() {
cur_doc="$(read_env_value "$env_file" "DOCUMENT_RUNTIME_HTTP_PORT" || printf '4321')"
cur_lk_url="$(read_env_value "$env_file" "LIVEKIT_URL" || printf 'ws://127.0.0.1:17880')"
cur_lk_http="$(read_livekit_override_port "$override_file" "http" "17880")"
- cur_lk_tcp="$(read_livekit_override_port "$override_file" "tcp_port" "7881")"
- cur_lk_udp="$(read_livekit_override_port "$override_file" "udp_port" "7882")"
+ cur_lk_tcp="$(read_livekit_override_port "$override_file" "rtc[.]tcp_port" "7881")"
+ cur_lk_udp="$(read_livekit_override_port "$override_file" "udp-port" "7882")"
local reserved=" $cur_pg $cur_th $cur_web $cur_node $cur_doc $cur_lk_http $cur_lk_tcp $cur_lk_udp "
local new_pg="$cur_pg"
@@ -665,20 +665,19 @@ ensure_compose_ports() {
fi
fi
if [[ "$new_lk_http" != "$cur_lk_http" || "$new_lk_tcp" != "$cur_lk_tcp" || "$new_lk_udp" != "$cur_lk_udp" ]]; then
+ local compose_version=""
+ compose_version="$(docker compose version --short 2>/dev/null || true)"
+ if [[ ! "$compose_version" =~ ^v?([0-9]+)\.([0-9]+)\.([0-9]+) ]] ||
+ ! (( BASH_REMATCH[1] > 2 ||
+ (BASH_REMATCH[1] == 2 && (BASH_REMATCH[2] > 24 ||
+ (BASH_REMATCH[2] == 24 && BASH_REMATCH[3] >= 4))) )); then
+ die "Automatic LiveKit port reassignment requires Docker Compose 2.24.4 or later. Update Docker Compose and rerun $SELF_CMD."
+ fi
mkdir -p "$(dirname "$override_file")"
cat > "$override_file" <<EOF
services:
livekit:
- command:
- - --config-body
- - |
- port: 7880
- rtc:
- tcp_port: $new_lk_tcp
- udp_port: $new_lk_udp
- use_external_ip: false
- logging:
- level: info
+ entrypoint: /livekit-server --rtc.tcp_port $new_lk_tcp --udp-port $new_lk_udp
ports: !override
- "127.0.0.1:$new_lk_http:7880"
- "\${LIVEKIT_RTC_BIND_ADDRESS:-127.0.0.1}:$new_lk_tcp:$new_lk_tcp"