Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

update.ts

588 lines23.5 KB

1import {
2 HostProcessArchitecture,
3 HostProcessEnvironment,
4 HostProcessInvokedAs,
5 HostProcessIsExecutable,
6 HostProcessPlatform,
7 HostProcessWorkingDirectory,
8} from "@t3tools/shared/hostProcess";
9import {
10 CLI_RELEASE_BASE_URL_ENV,
11 CLI_RELEASE_CHANNELS,
12 cliReleaseIndexPageUrl,
13 cliReleaseChannelOf,
14 newestCliReleaseVersion,
15 type CliReleaseChannel,
16} from "@t3tools/shared/cliRelease";
17import * as Console from "effect/Console";
18import * as Duration from "effect/Duration";
19import * as Effect from "effect/Effect";
20import * as FileSystem from "effect/FileSystem";
21import * as Layer from "effect/Layer";
22import * as Option from "effect/Option";
23import * as Path from "effect/Path";
24import * as Schema from "effect/Schema";
25import { Argument, Command, Flag, GlobalFlag, Prompt } from "effect/unstable/cli";
26import {
27 FetchHttpClient,
28 HttpClient,
29 HttpClientRequest,
30 HttpClientResponse,
31} from "effect/unstable/http";
32​
33import packageJson from "../../package.json" with { type: "json" };
34import * as BootService from "../cloud/bootService.ts";
35import {
36 ensurePinnedRuntimeInstalled,
37 pinnedRuntimeCommand,
38 PinnedRuntimeInstallError,
39 pinnedRuntimePaths,
40} from "../cloud/pinnedRuntime.ts";
41import { compareExactServiceVersions, isExactServiceVersion } from "../cloud/serviceProtocol.ts";
42import * as ProcessRunner from "../processRunner.ts";
43import { isProcessAlive, readPersistedServerRuntimeState } from "../serverRuntimeState.ts";
44import { projectLocationFlags, resolveCliAuthConfig } from "./config.ts";
45import { bootServiceLayer } from "./service.ts";
46​
47export class CliUpdateError extends Schema.TaggedError<CliUpdateError>()("CliUpdateError", {
48 reason: Schema.String,
49}) {
50 override get message(): string {
51 return this.reason;
52 }
54​
55const ReleaseIndex = Schema.Array(
56 Schema.Struct({
57 tag_name: Schema.String,
58 draft: Schema.optional(Schema.Boolean),
59 }),
60);
61const decodeReleaseIndex = Schema.decodeUnknownEffect(Schema.fromJsonString(ReleaseIndex));
62​
63const RELEASE_INDEX_TIMEOUT = Duration.seconds(30);
64// Enough to walk past a long run of nightlies without hammering the API when
65// a channel genuinely has nothing published.
66const RELEASE_INDEX_MAX_PAGES = 10;
67​
68/** Asks GitHub for the newest published version on a channel, page by page. */
69const resolveNewestVersion = Effect.fn("cli.update.resolve_newest")(function* (
70 channel: CliReleaseChannel,
71) {
72 const httpClient = yield* HttpClient.HttpClient;
73 for (let page = 1; page <= RELEASE_INDEX_MAX_PAGES; page += 1) {
74 const body = yield* httpClient
75 .execute(
76 HttpClientRequest.get(cliReleaseIndexPageUrl(page)).pipe(
77 HttpClientRequest.setHeader("Accept", "application/vnd.github+json"),
78 ),
79 )
80 .pipe(
81 Effect.flatMap(HttpClientResponse.filterStatusOk),
82 Effect.flatMap((response) => response.text),
83 Effect.mapError(() => new CliUpdateError({ reason: "Could not list t3 releases." })),
84 Effect.timeoutOrElse({
85 duration: RELEASE_INDEX_TIMEOUT,
86 orElse: () =>
87 Effect.fail(new CliUpdateError({ reason: "Timed out listing t3 releases." })),
88 }),
89 );
90 const releases = yield* decodeReleaseIndex(body).pipe(
91 Effect.mapError(
92 () => new CliUpdateError({ reason: "The t3 release index had an unexpected shape." }),
93 ),
94 );
95 const version = newestCliReleaseVersion(releases, channel);
96 if (version !== undefined) return version;
97 if (releases.length === 0) break;
98 }
99 return yield* new CliUpdateError({ reason: `No published ${channel} release was found.` });
100});
101​
102/** Whether a launcher target lives inside `<baseDir>/runtime/versions`. */
103export function launcherOwnsVersionsDir(
104 path: Path.Path,
105 versionsDir: string,
106 candidate: string,
107): boolean {
108 const relative = path.relative(versionsDir, path.resolve(candidate));
109 return relative.length > 0 && !relative.startsWith("..") && !path.isAbsolute(relative);
111​
112/**
113 * The launcher the install scripts leave behind: a symlink at `<bin>/t3` on
114 * POSIX, a `t3.cmd` shim on Windows. `t3 update` repoints it so the next `t3`
115 * invocation is the new version. Only a launcher that already points into
116 * this home's `runtime/versions` tree is touched; a plain copy of the
117 * executable, or a launcher for some other install, is left alone.
118 */
119export const repointLauncher = Effect.fn("cli.update.repoint_launcher")(function* (input: {
120 /** Path the current process was started through, if known. */
121 readonly launchedAs: string | undefined;
122 /** `<baseDir>/runtime/versions` of the home being updated. */
123 readonly versionsDir: string;
124 readonly targetEntryPath: string;
125}) {
126 const fs = yield* FileSystem.FileSystem;
127 const path = yield* Path.Path;
128 const platform = yield* HostProcessPlatform;
129 if (input.launchedAs === undefined) return Option.none<string>();
130 const ownsTarget = (candidate: string) =>
131 launcherOwnsVersionsDir(path, input.versionsDir, candidate);
132​
133 if (platform === "win32") {
134 // The shim runs the executable by absolute path, so the executable sees
135 // itself as argv0; the shim is the `t3.cmd` next to it only when launched
136 // from an install script's bin directory. Find it by searching the
137 // directories that would resolve `t3` on this shell's PATH.
138 const shimPath = yield* findWindowsShim(input.launchedAs);
139 if (shimPath === undefined) return Option.none<string>();
140 const current = yield* fs.readFileString(shimPath).pipe(Effect.option);
141 const quoted = Option.isSome(current) ? /^"([^"]+)"/m.exec(current.value)?.[1] : undefined;
142 if (quoted === undefined || !ownsTarget(quoted)) return Option.none<string>();
143 yield* fs
144 .writeFileString(shimPath, `@echo off\r\n"${input.targetEntryPath}" %*`)
145 .pipe(
146 Effect.mapError(
147 () => new CliUpdateError({ reason: `Could not rewrite the t3 launcher at ${shimPath}.` }),
148 ),
149 );
150 return Option.some(shimPath);
151 }
152​
153 const linkTarget = yield* fs.readLink(input.launchedAs).pipe(Effect.option);
154 if (Option.isNone(linkTarget)) return Option.none<string>();
155 const resolvedTarget = path.resolve(path.dirname(input.launchedAs), linkTarget.value);
156 if (!ownsTarget(resolvedTarget)) return Option.none<string>();
157 const tempLink = `${input.launchedAs}.${process.pid}.tmp`;
158 yield* fs.symlink(input.targetEntryPath, tempLink).pipe(
159 Effect.andThen(fs.rename(tempLink, input.launchedAs)),
160 Effect.mapError(
161 () =>
162 new CliUpdateError({ reason: `Could not repoint the t3 launcher at ${input.launchedAs}.` }),
163 ),
164 );
165 return Option.some(input.launchedAs);
166});
167​
168/**
169 * The path the executable was started through. Node keeps the shell's
170 * spelling in argv0: a launcher symlink or `./t3` resolves against the
171 * working directory, while a bare `t3` was found on PATH and has to be
172 * looked up there again, or the launcher symlink is never seen.
173 */
174export const resolveLauncherPath = Effect.gen(function* () {
175 const path = yield* Path.Path;
176 const fs = yield* FileSystem.FileSystem;
177 const invokedAs = yield* HostProcessInvokedAs;
178 const cwd = yield* HostProcessWorkingDirectory;
179 const environment = yield* HostProcessEnvironment;
180 const platform = yield* HostProcessPlatform;
181 if (invokedAs.includes("/") || invokedAs.includes("\\")) {
182 return path.resolve(cwd, invokedAs);
183 }
184 const delimiter = platform === "win32" ? ";" : ":";
185 for (const directory of (environment["PATH"] ?? "").split(delimiter)) {
186 if (directory.length === 0) continue;
187 const candidate = path.join(directory, invokedAs);
188 if (yield* fs.exists(candidate).pipe(Effect.orElseSucceed(() => false))) {
189 return candidate;
190 }
191 }
192 return undefined;
193});
194​
195/**
196 * On Windows a `.cmd` shim is what PATH resolves, but the executable it runs
197 * only ever sees its own path. Walk PATH for a `t3.cmd` whose target is the
198 * running executable; that is the launcher the install script wrote.
199 */
200export const findWindowsShim = Effect.fn("cli.update.find_windows_shim")(function* (
201 executablePath: string,
202) {
203 const fs = yield* FileSystem.FileSystem;
204 const path = yield* Path.Path;
205 const environment = yield* HostProcessEnvironment;
206 const candidates = [
207 ...(environment["T3CODE_INSTALL_BIN_DIR"] ? [environment["T3CODE_INSTALL_BIN_DIR"]] : []),
208 ...(environment["PATH"] ?? environment["Path"] ?? "").split(";"),
209 ].filter((entry) => entry.trim().length > 0);
210 for (const directory of candidates) {
211 const shimPath = path.join(directory, "t3.cmd");
212 const contents = yield* fs.readFileString(shimPath).pipe(Effect.option);
213 if (Option.isNone(contents)) continue;
214 const target = /^"([^"]+)"/m.exec(contents.value)?.[1];
215 if (
216 target !== undefined &&
217 path.resolve(target).toLowerCase() === path.resolve(executablePath).toLowerCase()
218 ) {
219 return shimPath;
220 }
221 }
222 return undefined;
223});
224​
225const updateFlags = {
226 ...projectLocationFlags,
227 channel: Flag.choice("channel", CLI_RELEASE_CHANNELS).pipe(
228 Flag.withDescription(
229 "Release channel to follow. Defaults to the channel this t3 was published on.",
230 ),
231 Flag.optional,
232 ),
233 allowDowngrade: Flag.boolean("allow-downgrade").pipe(
234 Flag.withDescription("Allow moving to an older version than the one running."),
235 Flag.withDefault(false),
236 ),
237 yes: Flag.boolean("yes").pipe(
238 Flag.withAlias("y"),
239 Flag.withDescription(
240 "Restart the background service without asking. Required to restart it from a script, where there is no prompt.",
241 ),
242 Flag.withDefault(false),
243 ),
244};
245​
246const versionArgument = Argument.string("version").pipe(
247 Argument.withDescription(
248 "Exact version to install. Defaults to the newest release on the channel.",
249 ),
250 Argument.optional,
251);
252​
253export const updateCommand = Command.make("update", {
254 ...updateFlags,
255 version: versionArgument,
256}).pipe(
257 Command.withDescription(
258 "Download a newer t3 and switch this machine to it, including the background service when one is installed.",
259 ),
260 Command.withHandler((flags) =>
261 Effect.gen(function* () {
262 const logLevel = yield* GlobalFlag.LogLevel;
263 const config = yield* resolveCliAuthConfig(flags, logLevel);
264 return yield* runUpdate({
265 baseDir: config.baseDir,
266 logsDir: config.logsDir,
267 serverRuntimeStatePath: config.serverRuntimeStatePath,
268 channel: Option.getOrUndefined(flags.channel),
269 requestedVersion: Option.getOrUndefined(flags.version),
270 allowDowngrade: flags.allowDowngrade,
271 assumeYes: flags.yes,
272 }).pipe(
273 Effect.provide(
274 Layer.mergeAll(bootServiceLayer(config), ProcessRunner.layer, FetchHttpClient.layer),
275 ),
276 );
277 }),
278 ),
279);
280​
281/**
282 * A `t3 serve` or `t3` someone started by hand, as opposed to the one the
283 * background service supervises. The server records its pid on startup; a
284 * stale file from a crashed server is ignored by checking the pid is alive.
285 *
286 * Servers from before `serviceManaged` was recorded cannot be told apart by
287 * the file alone, so the launcher-supervised case is also recognised by
288 * lineage: a service server's parent is the launcher, and on Linux that
289 * launcher runs inside the unit's cgroup.
290 */
291const findForegroundServer = Effect.fn("cli.update.find_foreground_server")(function* (input: {
292 readonly serverRuntimeStatePath: string;
293 readonly serviceInstalled: boolean;
294}) {
295 const state = yield* readPersistedServerRuntimeState(input.serverRuntimeStatePath);
296 if (Option.isNone(state) || state.value.serviceManaged || !isProcessAlive(state.value.pid)) {
297 return undefined;
298 }
299 if (input.serviceInstalled && (yield* belongsToBootService(state.value.pid))) return undefined;
300 return state.value;
301});
302​
303const belongsToBootService = Effect.fn("cli.update.belongs_to_boot_service")(function* (
304 pid: number,
305) {
306 const platform = yield* HostProcessPlatform;
307 const fs = yield* FileSystem.FileSystem;
308 const runner = yield* ProcessRunner.ProcessRunner;
309 if (platform === "linux") {
310 const cgroup = yield* fs.readFileString(`/proc/${pid}/cgroup`).pipe(Effect.option);
311 return Option.isSome(cgroup) && cgroup.value.includes("/t3code.service");
312 }
313 if (platform === "darwin") {
314 // The service server's parent is the launcher process.
315 const parent = yield* runner
316 .run({
317 command: "ps",
318 args: ["-o", "ppid=", "-p", String(pid)],
319 timeout: Duration.seconds(5),
320 })
321 .pipe(Effect.option);
322 const ppid = Option.isSome(parent) && parent.value.code === 0 ? parent.value.stdout.trim() : "";
323 if (!/^\d+$/.test(ppid)) return false;
324 const command = yield* runner
325 .run({ command: "ps", args: ["-o", "command=", "-p", ppid], timeout: Duration.seconds(5) })
326 .pipe(
327 Effect.map((result) => (result.code === 0 ? result.stdout : "")),
328 Effect.orElseSucceed(() => ""),
329 );
330 return /__service-launcher/.test(command);
331 }
332 return false;
333});
334​
335const runUpdate = Effect.fn("cli.update.run")(function* (input: {
336 readonly baseDir: string;
337 readonly logsDir: string;
338 readonly serverRuntimeStatePath: string;
339 readonly channel: CliReleaseChannel | undefined;
340 readonly requestedVersion: string | undefined;
341 readonly allowDowngrade: boolean;
342 readonly assumeYes: boolean;
343}) {
344 const fs = yield* FileSystem.FileSystem;
345 const path = yield* Path.Path;
346 const runner = yield* ProcessRunner.ProcessRunner;
347 const platform = yield* HostProcessPlatform;
348 const arch = yield* HostProcessArchitecture;
349 const environment = yield* HostProcessEnvironment;
350 const httpClient = yield* HttpClient.HttpClient;
351 const service = yield* BootService.BootService;
352​
353 const currentVersion = packageJson.version;
354 const channel = input.channel ?? cliReleaseChannelOf(currentVersion);
355 if (input.requestedVersion !== undefined && !isExactServiceVersion(input.requestedVersion)) {
356 return yield* new CliUpdateError({
357 reason: `'${input.requestedVersion}' is not an exact t3 version.`,
358 });
359 }
360 const targetVersion = input.requestedVersion ?? (yield* resolveNewestVersion(channel));
361 const targetChannel = cliReleaseChannelOf(targetVersion);
362​
363 // Preview is a maintainers' dogfooding train: it is cut by hand from
364 // unmerged branches, receives no fixes, and is never offered to anyone.
365 // Reaching it from stable or nightly takes an explicit ask and an explicit
366 // acknowledgement; the flag alone is not enough from a script.
367 const currentChannel = cliReleaseChannelOf(currentVersion);
368 if (targetChannel === "preview" && currentChannel !== "preview") {
369 yield* Console.log(
370 [
371 `t3@${targetVersion} is a preview build.`,
372 " Preview builds are cut by maintainers from unreleased branches to exercise the release",
373 " pipeline. They can be broken, receive no fixes, and are never offered as updates; you",
374 ` will have to switch back to ${currentChannel} yourself with \`t3 update --channel ${currentChannel} --allow-downgrade\`.`,
375 ].join("\n"),
376 );
377 if (!(process.stdin.isTTY && process.stdout.isTTY)) {
378 return yield* new CliUpdateError({
379 reason:
380 "Refusing to install a preview build without confirmation. Run this from a terminal to confirm, or pass --channel preview from an interactive shell.",
381 });
382 }
383 const confirmed = yield* Prompt.run(
384 Prompt.confirm({ message: "Install the preview build anyway?", initial: false }),
385 ).pipe(Effect.catchTag("QuitError", () => Effect.succeed(false)));
386 if (!confirmed) {
387 yield* Console.log("Left as is.");
388 return;
389 }
390 }
391​
392 // Work out everything that will be touched before touching anything, so the
393 // user sees one plan and one question rather than a surprise restart.
394 const status = yield* service.status;
395 // The unit name is per user, not per T3 home. Only touch the service when it
396 // serves the home this update targets; otherwise it belongs to another
397 // install on this machine and restarting it would take that server down.
398 const servesThisHome =
399 status.installedBaseDir !== undefined &&
400 path.resolve(status.installedBaseDir) === path.resolve(input.baseDir);
401 const serviceInstalled = status.supported && status.installed && servesThisHome;
402 const foreground = yield* findForegroundServer({
403 serverRuntimeStatePath: input.serverRuntimeStatePath,
404 serviceInstalled,
405 });
406 // What this machine runs is the executable behind the launcher and, when a
407 // service is installed for this home, the version that service runs. Either
408 // being stale is an update to do, and the newest of the two is what the
409 // downgrade check protects.
410 const serviceVersion = serviceInstalled ? status.installedVersion : undefined;
411 const executableCurrent = targetVersion === currentVersion;
412 // A service whose recorded version is missing or unreadable is not known
413 // to be current, so it gets the update rather than being skipped. Nor is
414 // one on the right version that is stopped, disabled, or still running the
415 // version before it (an earlier update where the restart was declined):
416 // `status.current` covers all of that when the target is this executable,
417 // and the problem list is what can be judged for any other target.
418 const restartPending = status.problems?.includes("restart-pending") === true;
419 const serviceCurrent =
420 !serviceInstalled ||
421 (serviceVersion === targetVersion &&
422 (executableCurrent ? status.current : (status.problems ?? []).length === 0));
423 const newestInstalled =
424 serviceVersion !== undefined && compareExactServiceVersions(serviceVersion, currentVersion) > 0
425 ? serviceVersion
426 : currentVersion;
427​
428 if (executableCurrent && serviceCurrent) {
429 yield* Console.log(
430 serviceVersion !== undefined
431 ? `t3 and its background service are already on ${targetVersion} (${targetChannel}).`
432 : `t3 is already on ${targetVersion} (${targetChannel}).`,
433 );
434 return;
435 }
436 if (!input.allowDowngrade && compareExactServiceVersions(targetVersion, newestInstalled) < 0) {
437 return yield* new CliUpdateError({
438 reason: `t3@${targetVersion} is older than the installed ${newestInstalled}. Pass --allow-downgrade to install it anyway.`,
439 });
440 }
441​
442 const alreadyOnDisk = yield* fs
443 .readFileString(pinnedRuntimePaths(path, input.baseDir, targetVersion, platform).sentinelPath)
444 .pipe(
445 Effect.map((sentinel) => sentinel.trim() === targetVersion),
446 Effect.orElseSucceed(() => false),
447 );
448​
449 yield* Console.log(
450 executableCurrent && restartPending
451 ? `The background service is still running the version before ${targetVersion} (${targetChannel}).`
452 : executableCurrent
453 ? `Updating the background service ${serviceVersion ?? "(unknown version)"} -> ${targetVersion} (${targetChannel}).`
454 : alreadyOnDisk
455 ? `Switching t3 ${currentVersion} -> ${targetVersion} (${targetChannel}, already downloaded).`
456 : `Updating t3 ${currentVersion} -> ${targetVersion} (${targetChannel}).`,
457 );
458 let restartService = false;
459 if (serviceInstalled && !serviceCurrent) {
460 yield* Console.log(
461 " A background service is installed for this T3 home. Restarting it interrupts anything running in it: agent turns, terminals, remote clients.",
462 );
463 if (input.assumeYes) {
464 restartService = true;
465 } else if (process.stdin.isTTY && process.stdout.isTTY) {
466 restartService = yield* Prompt.run(
467 Prompt.confirm({
468 message: "Restart the background service once the download is verified?",
469 initial: true,
470 }),
471 ).pipe(Effect.catchTag("QuitError", () => Effect.succeed(false)));
472 } else {
473 yield* Console.log(
474 " Not a terminal, so the service keeps running its current version. Rerun with --yes to restart it now, or run `t3 service restart` later.",
475 );
476 }
477 }
478​
479 const runtime = yield* ensurePinnedRuntimeInstalled({
480 baseDir: input.baseDir,
481 version: targetVersion,
482 fs,
483 path,
484 runner,
485 httpClient,
486 platform,
487 arch,
488 releaseBaseUrl: environment[CLI_RELEASE_BASE_URL_ENV]?.trim() || undefined,
489 validate: (paths) =>
490 runner
491 .run({
492 command: pinnedRuntimeCommand(paths).command,
493 args: [...pinnedRuntimeCommand(paths).args, "--version"],
494 timeout: Duration.seconds(30),
495 })
496 .pipe(
497 Effect.mapError(
498 (cause) =>
499 new PinnedRuntimeInstallError({ step: "verifying the downloaded t3", cause }),
500 ),
501 Effect.flatMap((result) =>
502 result.code === 0 && /\bv(\S+)\s*$/.exec(result.stdout)?.[1] === targetVersion
503 ? Effect.void
504 : Effect.fail(
505 new PinnedRuntimeInstallError({
506 step: "verifying the downloaded t3",
507 exitCode: Number(result.code),
508 }),
509 ),
510 ),
511 ),
512 }).pipe(
513 Effect.catchIf(
514 (error): error is PinnedRuntimeInstallError =>
515 error._tag === "PinnedRuntimeInstallError" &&
516 error.step.startsWith("downloading the t3 release checksums") &&
517 String(error.cause).includes("404"),
518 () =>
519 Effect.fail(
520 new CliUpdateError({
521 reason: `No release archive was published for t3@${targetVersion}.`,
522 }),
523 ),
524 ),
525 );
526​
527 const launchedAs = (yield* HostProcessIsExecutable) ? yield* resolveLauncherPath : undefined;
528 const repointed = yield* repointLauncher({
529 launchedAs,
530 versionsDir: path.dirname(runtime.versionDir),
531 targetEntryPath: runtime.entryPath,
532 });
533​
534 // The service switch runs in this process against the target version: the
535 // downloaded runtime has already proven it runs (the `--version` check
536 // above), and doing it here rather than through the target's own CLI means
537 // a downgrade to a version without today's commands still works. The unit
538 // is rewritten either way so a later `t3 service restart` lands on the new
539 // version; only the restart itself waits for the user's answer.
540 let serviceUpdated = false;
541 if (serviceInstalled && !serviceCurrent) {
542 yield* BootService.BootService.pipe(
543 Effect.flatMap((target) =>
544 target.install({ allowDowngrade: input.allowDowngrade, start: restartService }),
545 ),
546 Effect.provide(
547 BootService.layer({
548 baseDir: input.baseDir,
549 logsDir: input.logsDir,
550 cliVersion: targetVersion,
551 }),
552 ),
553 Effect.mapError(
554 (error) =>
555 new CliUpdateError({
556 reason: `t3@${targetVersion} is installed but the background service could not be ${restartService ? "updated" : "pointed at it"}: ${error.message}`,
557 }),
558 ),
559 );
560 serviceUpdated = restartService;
561 }
562​
563 yield* Console.log("");
564 yield* Console.log(`t3 ${targetVersion} is installed at ${runtime.entryPath}`);
565 if (Option.isSome(repointed)) {
566 yield* Console.log(` ${repointed.value} now runs ${targetVersion}`);
567 } else {
568 yield* Console.log(` Run it as ${runtime.entryPath}, or point your \`t3\` launcher at it.`);
569 }
570 if (serviceUpdated) {
571 yield* Console.log(` Background service restarted on ${targetVersion}`);
572 } else if (serviceInstalled && serviceCurrent) {
573 yield* Console.log(` Background service already on ${targetVersion}`);
574 } else if (serviceInstalled) {
575 yield* Console.log(
576 ` Background service still running ${serviceVersion ?? "an unknown version"}. Run \`t3 service restart\` when you are ready to switch it to ${targetVersion}.`,
577 );
578 } else if (status.installed && !servesThisHome) {
579 yield* Console.log(
580 ` The background service serves ${status.installedBaseDir ?? "another T3 home"} and was left unchanged.`,
581 );
582 }
583 if (foreground !== undefined) {
584 yield* Console.log(
585 ` A server started by hand is still running at ${foreground.origin} (pid ${foreground.pid}). Stop it and start it again to pick up ${targetVersion}.`,
586 );
587 }
588});