The best way to control Claude Code, Codex and more from any computer or phone
fix(server): stop npx service updates from silently leaving the old server running (#5217)
Co-authored-by: Claude <noreply@anthropic.com>
Theo Browne committed
Aug 1, 2026 at 22:42 UTC
64bf0161919ec0e41470af3304928d9fc8711bf4
2 files changed
+22
-15
apps/server/src/cloud/bootService.test.ts
+17
-2
@@ -33,6 +33,7 @@ it("keeps systemd pinned to the stable launcher rather than a versioned server",
33
34
const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
35
platform: NodeJS.Platform = "linux",
36
+ usePinnedLauncher = false,
37
) {
38
const fs = yield* FileSystem.FileSystem;
39
const path = yield* Path.Path;
@@ -44,6 +45,10 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
45
const runtime = pinnedRuntimePaths(path, baseDir, "1.2.3");
46
yield* fs.makeDirectory(path.dirname(runtime.entryPath), { recursive: true });
47
yield* fs.writeFileString(runtime.entryPath, "export {};\n");
48
+ yield* fs.writeFileString(
49
+ path.join(path.dirname(runtime.entryPath), "service-launcher.mjs"),
50
+ "export const source = 'pinned runtime';\n",
51
+ );
52
yield* fs.writeFileString(runtime.sentinelPath, "1.2.3\n");
53
54
const commands: string[] = [];
@@ -69,8 +74,7 @@ const makeHarness = Effect.fn("test.make_boot_service_harness")(function* (
74
cliVersion: "1.2.3",
75
host: {
76
execPath: "/usr/bin/node",
72
- cliEntryPath: path.join(home, "bin.mjs"),
73
- launcherSourcePath: sourceLauncher,
77
+ ...(usePinnedLauncher ? {} : { launcherSourcePath: sourceLauncher }),
78
},
79
}).pipe(
80
Effect.provideService(ProcessRunner.ProcessRunner, runner),
@@ -109,6 +113,17 @@ it.layer(NodeServices.layer)("boot service install", (it) => {
113
}),
114
);
115
116
+ it.effect("copies the launcher from the prepared pinned runtime", () =>
117
+ Effect.gen(function* () {
118
+ const { service, fs } = yield* makeHarness("linux", true);
119
+ const plan = yield* service.install;
120
+
121
+ expect(yield* fs.readFileString(plan.launcherPath)).toBe(
122
+ "export const source = 'pinned runtime';\n",
123
+ );
124
+ }),
125
+ );
126
+
127
it.effect("restarts an installed service when repair fails", () =>
128
Effect.gen(function* () {
129
const { service, commands, control } = yield* makeHarness();
apps/server/src/cloud/bootService.ts
+5
-13
@@ -1,8 +1,4 @@
1
-import {
2
- HostProcessArguments,
3
- HostProcessExecutablePath,
4
- HostProcessPlatform,
5
-} from "@t3tools/shared/hostProcess";
1
+import { HostProcessExecutablePath, HostProcessPlatform } from "@t3tools/shared/hostProcess";
2
import * as Config from "effect/Config";
3
import * as Context from "effect/Context";
4
import * as DateTime from "effect/DateTime";
@@ -138,7 +134,6 @@ export class BootService extends Context.Service<
134
135
export interface BootServiceHost {
136
readonly execPath: string;
141
- readonly cliEntryPath: string;
137
readonly launcherSourcePath?: string;
138
}
139
@@ -148,26 +143,23 @@ export const make = Effect.fn("cloud.boot_service.make")(function* (input: {
143
readonly cliVersion: string;
144
readonly host?: BootServiceHost;
145
}) {
151
- const hostArguments = yield* HostProcessArguments;
146
const hostExecPath = yield* HostProcessExecutablePath;
147
const platform = yield* HostProcessPlatform;
148
const homeDir = yield* Config.string("HOME").pipe(Config.withDefault(""));
149
const fs = yield* FileSystem.FileSystem;
150
const path = yield* Path.Path;
151
const runner = yield* ProcessRunner.ProcessRunner;
158
- const host = input.host ?? {
159
- execPath: hostExecPath,
160
- cliEntryPath: hostArguments[1] ?? "",
161
- };
152
+ const host = input.host ?? { execPath: hostExecPath };
153
154
const unitDir = path.join(homeDir, ".config", "systemd", "user");
155
const unitPath = path.join(unitDir, BOOT_SERVICE_UNIT_FILE);
156
const logPath = path.join(input.logsDir, "boot-service.log");
157
const launcherPath = path.join(input.baseDir, "runtime", SERVICE_LAUNCHER_FILE);
158
const statePath = path.join(input.baseDir, "runtime", SERVICE_STATE_FILE);
168
- const launcherSourcePath =
169
- host.launcherSourcePath ?? path.join(path.dirname(host.cliEntryPath), SERVICE_LAUNCHER_FILE);
159
const runtimePaths = pinnedRuntimePaths(path, input.baseDir, input.cliVersion);
160
+ const launcherSourcePath =
161
+ host.launcherSourcePath ??
162
+ path.join(path.dirname(runtimePaths.entryPath), SERVICE_LAUNCHER_FILE);
163
const writeDurably = (filePath: string, contents: string) =>
164
Effect.scoped(
165
Effect.gen(function* () {