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

update.ts

608 lines23.3 KB

1import * as HostProcess from "@t3tools/shared/HostProcess";
2import {
3 CLI_RELEASE_BASE_URL_ENV,
4 CLI_RELEASE_CHANNELS,
5 cliReleaseIndexPageUrl,
6 cliReleaseChannelOf,
7 newestCliReleaseVersion,
8 releaseAssetUrl,
9 updateFeedFileName,
10 type CliReleaseChannel,
11} from "@t3tools/shared/cliRelease";
12import * as Console from "effect/Console";
13import * as Duration from "effect/Duration";
14import * as Effect from "effect/Effect";
15import * as FileSystem from "effect/FileSystem";
16import * as Layer from "effect/Layer";
17import * as Option from "effect/Option";
18import * as Path from "effect/Path";
19import * as Schema from "effect/Schema";
20import { Argument, Command, Flag, GlobalFlag, Prompt } from "effect/cli";
21import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
22​
23import packageJson from "../../package.json" with { type: "json" };
24import * as BootService from "../cloud/bootService.ts";
25import {
26 ensurePinnedRuntimeInstalled,
27 findPosixLauncher,
28 launcherOwnsVersionsDir,
29 pinnedRuntimeCommand,
30 isUnpublishedRelease,
31 PinnedRuntimeInstallError,
32 pinnedRuntimePaths,
33 pinnedRuntimeVersionsDir,
34 prunePinnedRuntimes,
35 recordPinnedRuntimeLauncher,
36 resolveLauncherPath,
37 windowsShimTarget,
38 writePosixLauncher,
39} from "../cloud/pinnedRuntime.ts";
40import { compareExactServiceVersions, isExactServiceVersion } from "../cloud/serviceProtocol.ts";
41import * as ManagedPolicy from "../policy/ManagedPolicy.ts";
42import { managedUpdateMirror, managedUpdateRefusal } from "../policy/managedUpdates.ts";
43import * as ProcessRunner from "../processRunner.ts";
44import { isProcessAlive, readPersistedServerRuntimeState } from "../serverRuntimeState.ts";
45import { projectLocationFlags, resolveCliAuthConfig } from "./config.ts";
46import { createUpdateProgress } from "./updateProgress.ts";
47import * as CliService from "./service.ts";
48​
49export class CliUpdateError extends Schema.TaggedError<CliUpdateError>()("CliUpdateError", {
50 reason: Schema.String,
51 cause: Schema.optional(Schema.Defect()),
52}) {
53 override get message(): string {
54 return this.reason;
55 }
57​
58const ReleaseIndex = Schema.Array(
59 Schema.Struct({
60 tag_name: Schema.String,
61 draft: Schema.optional(Schema.Boolean),
62 }),
63);
64const decodeReleaseIndex = Schema.decodeUnknownEffect(Schema.fromJsonString(ReleaseIndex));
65​
66const RELEASE_INDEX_TIMEOUT = Duration.seconds(30);
67const RELEASE_INDEX_MAX_PAGES = 10;
68​
69export const resolveNewestVersion = Effect.fn("cli.update.resolve_newest")(function* (
70 channel: CliReleaseChannel,
71) {
72 const httpClient = yield* HttpClient.HttpClient;
73 const environment = yield* HostProcess.Environment;
74 const githubToken = environment.GH_TOKEN?.trim() || environment.GITHUB_TOKEN?.trim() || undefined;
75 for (let page = 1; page <= RELEASE_INDEX_MAX_PAGES; page += 1) {
76 const request = HttpClientRequest.get(cliReleaseIndexPageUrl(page)).pipe(
77 HttpClientRequest.setHeader("Accept", "application/vnd.github+json"),
78 );
79 const authenticatedRequest =
80 githubToken === undefined
81 ? request
82 : HttpClientRequest.setHeader(request, "Authorization", `Bearer ${githubToken}`);
83 const body = yield* httpClient.execute(authenticatedRequest).pipe(
84 Effect.flatMap(HttpClientResponse.filterStatusOk),
85 Effect.flatMap((response) => response.text),
86 Effect.mapError(() => new CliUpdateError({ reason: "Could not list t3 releases." })),
87 Effect.timeoutOrElse({
88 duration: RELEASE_INDEX_TIMEOUT,
89 orElse: () => Effect.fail(new CliUpdateError({ reason: "Timed out listing t3 releases." })),
90 }),
91 );
92 const releases = yield* decodeReleaseIndex(body).pipe(
93 Effect.mapError(
94 () => new CliUpdateError({ reason: "The t3 release index had an unexpected shape." }),
95 ),
96 );
97 const version = newestCliReleaseVersion(releases, channel);
98 if (version !== undefined) return version;
99 if (releases.length === 0) break;
100 }
101 return yield* new CliUpdateError({ reason: `No published ${channel} release was found.` });
102});
103​
104/** The version an update mirror's feed file for this platform offers on `channel`. */
105export const resolveMirrorVersion = Effect.fn("cli.update.resolve_mirror")(function* (
106 mirror: { readonly organization: string; readonly feedUrl: string },
107 channel: CliReleaseChannel,
108) {
109 if (channel === "preview") {
110 return yield* new CliUpdateError({
111 reason: `${mirror.organization}'s update mirror has no preview builds.`,
112 });
113 }
114 const httpClient = yield* HttpClient.HttpClient;
115 const fileName = updateFeedFileName(
116 channel === "nightly" ? "nightly" : "latest",
117 yield* HostProcess.Platform,
118 yield* HostProcess.Architecture,
119 );
120 const url = releaseAssetUrl(mirror.feedUrl, fileName);
121 // Not the URL, whose query can hold the mirror's access token.
122 const unreadable = new CliUpdateError({
123 reason: `Could not read ${fileName} from ${mirror.organization}'s update mirror.`,
124 });
125 const body = yield* httpClient.get(url).pipe(
126 Effect.flatMap(HttpClientResponse.filterStatusOk),
127 Effect.flatMap((response) => response.text),
128 Effect.mapError(() => unreadable),
129 Effect.timeoutOrElse({
130 duration: RELEASE_INDEX_TIMEOUT,
131 orElse: () => Effect.fail(unreadable),
132 }),
133 );
134 const version = /^version:\s*["']?([^"'\s]+)/m.exec(body)?.[1];
135 if (
136 version === undefined ||
137 !isExactServiceVersion(version) ||
138 cliReleaseChannelOf(version) !== channel
139 ) {
140 return yield* unreadable;
141 }
142 return version;
143});
144​
145/**
146 * Only a launcher that already points into this home's `runtime/versions` tree is touched; a
147 * plain copy of the executable, or a launcher for some other install, is left alone. It is
148 * recorded before it moves, so prune never meets a repointed launcher it does not know about.
149 */
150export const repointLauncher = Effect.fn("cli.update.repoint_launcher")(function* (input: {
151 readonly launchedAs: string | undefined;
152 readonly baseDir: string;
153 readonly targetEntryPath: string;
154}) {
155 const fs = yield* FileSystem.FileSystem;
156 const path = yield* Path.Path;
157 const platform = yield* HostProcess.Platform;
158 if (input.launchedAs === undefined) return Option.none<string>();
159 const versionsDir = pinnedRuntimeVersionsDir(path, input.baseDir);
160 const ownsTarget = (candidate: string) => launcherOwnsVersionsDir(path, versionsDir, candidate);
161 const remember = (launcher: string) =>
162 recordPinnedRuntimeLauncher({ baseDir: input.baseDir, launcher }).pipe(
163 Effect.mapError(
164 () => new CliUpdateError({ reason: `Could not record the t3 launcher at ${launcher}.` }),
165 ),
166 );
167​
168 if (platform === "win32") {
169 const shimPath = yield* findWindowsShim(input.launchedAs);
170 if (shimPath === undefined) return Option.none<string>();
171 const current = yield* fs.readFileString(shimPath).pipe(Effect.option);
172 const quoted = Option.isSome(current) ? windowsShimTarget(current.value) : undefined;
173 if (quoted === undefined || !ownsTarget(quoted)) return Option.none<string>();
174 yield* remember(shimPath);
175 yield* fs
176 .writeFileString(shimPath, `@echo off\r\n"${input.targetEntryPath}" %*`)
177 .pipe(
178 Effect.mapError(
179 () => new CliUpdateError({ reason: `Could not rewrite the t3 launcher at ${shimPath}.` }),
180 ),
181 );
182 return Option.some(shimPath);
183 }
184​
185 const launcher = yield* findPosixLauncher({ launchedAs: input.launchedAs, versionsDir });
186 if (launcher === undefined) return Option.none<string>();
187 yield* remember(launcher);
188 yield* writePosixLauncher({
189 launcher,
190 executable: input.targetEntryPath,
191 exclusive: false,
192 }).pipe(
193 Effect.mapError(
194 (cause) =>
195 new CliUpdateError({ reason: `Could not repoint the t3 launcher at ${launcher}.`, cause }),
196 ),
197 );
198 return Option.some(launcher);
199});
200​
201/** Windows executables see their own path, so find the installer shim by matching t3.cmd targets on PATH. */
202export const findWindowsShim = Effect.fn("cli.update.find_windows_shim")(function* (
203 executablePath: string,
204) {
205 const fs = yield* FileSystem.FileSystem;
206 const path = yield* Path.Path;
207 const environment = yield* HostProcess.Environment;
208 const candidates = [
209 ...(environment["T3CODE_INSTALL_BIN_DIR"] ? [environment["T3CODE_INSTALL_BIN_DIR"]] : []),
210 ...(environment["PATH"] ?? environment["Path"] ?? "").split(";"),
211 ].filter((entry) => entry.trim().length > 0);
212 for (const directory of candidates) {
213 const shimPath = path.join(directory, "t3.cmd");
214 const contents = yield* fs.readFileString(shimPath).pipe(Effect.option);
215 if (Option.isNone(contents)) continue;
216 const target = windowsShimTarget(contents.value);
217 if (
218 target !== undefined &&
219 path.resolve(target).toLowerCase() === path.resolve(executablePath).toLowerCase()
220 ) {
221 return shimPath;
222 }
223 }
224 return undefined;
225});
226​
227const updateFlags = {
228 ...projectLocationFlags,
229 channel: Flag.Literals("channel", CLI_RELEASE_CHANNELS).pipe(
230 Flag.withDescription(
231 "Release channel to follow. Defaults to the channel this t3 was published on.",
232 ),
233 Flag.optional,
234 ),
235 allowDowngrade: Flag.Boolean("allow-downgrade").pipe(
236 Flag.withDescription("Allow moving to an older version than the one running."),
237 Flag.withDefault(false),
238 ),
239 yes: Flag.Boolean("yes").pipe(
240 Flag.withAlias("y"),
241 Flag.withDescription(
242 "Restart the background service without asking. Required to restart it from a script, where there is no prompt.",
243 ),
244 Flag.withDefault(false),
245 ),
246};
247​
248const versionArgument = Argument.String("version").pipe(
249 Argument.withDescription(
250 "Exact version to install. Defaults to the newest release on the channel.",
251 ),
252 Argument.optional,
253);
254​
255export const updateCommand = Command.make("update", {
256 ...updateFlags,
257 version: versionArgument,
258}).pipe(
259 Command.withDescription(
260 "Download a newer t3 and switch this machine to it, including the background service when one is installed.",
261 ),
262 Command.withHandler((flags) =>
263 Effect.gen(function* () {
264 const logLevel = yield* GlobalFlag.LogLevel;
265 const config = yield* resolveCliAuthConfig(flags, logLevel);
266 return yield* runUpdate({
267 baseDir: config.baseDir,
268 logsDir: config.logsDir,
269 serverRuntimeStatePath: config.serverRuntimeStatePath,
270 channel: Option.getOrUndefined(flags.channel),
271 requestedVersion: Option.getOrUndefined(flags.version),
272 allowDowngrade: flags.allowDowngrade,
273 assumeYes: flags.yes,
274 }).pipe(
275 Effect.provide(
276 Layer.mergeAll(
277 CliService.layer(config),
278 ProcessRunner.layer,
279 FetchHttpClient.layer,
280 ManagedPolicy.layer,
281 ),
282 ),
283 );
284 }),
285 ),
286);
287​
288const findForegroundServer = Effect.fn("cli.update.find_foreground_server")(function* (input: {
289 readonly serverRuntimeStatePath: string;
290 readonly serviceInstalled: boolean;
291}) {
292 const state = yield* readPersistedServerRuntimeState(input.serverRuntimeStatePath);
293 if (Option.isNone(state) || state.value.serviceManaged || !isProcessAlive(state.value.pid)) {
294 return undefined;
295 }
296 if (input.serviceInstalled && (yield* belongsToBootService(state.value.pid))) return undefined;
297 return state.value;
298});
299​
300const belongsToBootService = Effect.fn("cli.update.belongs_to_boot_service")(function* (
301 pid: number,
302) {
303 const platform = yield* HostProcess.Platform;
304 const fs = yield* FileSystem.FileSystem;
305 const runner = yield* ProcessRunner.ProcessRunner;
306 if (platform === "linux") {
307 const cgroup = yield* fs.readFileString(`/proc/${pid}/cgroup`).pipe(Effect.option);
308 return Option.isSome(cgroup) && cgroup.value.includes("/t3code.service");
309 }
310 if (platform === "darwin") {
311 const parent = yield* runner
312 .run({
313 command: "ps",
314 args: ["-o", "ppid=", "-p", String(pid)],
315 timeout: Duration.seconds(5),
316 })
317 .pipe(Effect.option);
318 const ppid = Option.isSome(parent) && parent.value.code === 0 ? parent.value.stdout.trim() : "";
319 if (!/^\d+$/.test(ppid)) return false;
320 const command = yield* runner
321 .run({ command: "ps", args: ["-o", "command=", "-p", ppid], timeout: Duration.seconds(5) })
322 .pipe(
323 Effect.map((result) => (result.code === 0 ? result.stdout : "")),
324 Effect.orElseSucceed(() => ""),
325 );
326 return /__service-launcher/.test(command);
327 }
328 return false;
329});
330​
331export const runUpdate = Effect.fn("cli.update.run")(function* (input: {
332 readonly baseDir: string;
333 readonly logsDir: string;
334 readonly serverRuntimeStatePath: string;
335 readonly channel: CliReleaseChannel | undefined;
336 readonly requestedVersion: string | undefined;
337 readonly allowDowngrade: boolean;
338 readonly assumeYes: boolean;
339}) {
340 const fs = yield* FileSystem.FileSystem;
341 const path = yield* Path.Path;
342 const runner = yield* ProcessRunner.ProcessRunner;
343 const platform = yield* HostProcess.Platform;
344 const arch = yield* HostProcess.Architecture;
345 const environment = yield* HostProcess.Environment;
346 const httpClient = yield* HttpClient.HttpClient;
347 const service = yield* BootService.BootService;
348 const policy = yield* ManagedPolicy.ManagedPolicy;
349 const mirror = managedUpdateMirror(policy.document);
350​
351 const currentVersion = packageJson.version;
352 const channel = input.channel ?? cliReleaseChannelOf(currentVersion);
353 const refusal = managedUpdateRefusal(
354 policy.document,
355 input.requestedVersion === undefined ? channel : cliReleaseChannelOf(input.requestedVersion),
356 );
357 if (refusal !== undefined) {
358 return yield* new CliUpdateError({ reason: refusal });
359 }
360 if (input.requestedVersion !== undefined && !isExactServiceVersion(input.requestedVersion)) {
361 return yield* new CliUpdateError({
362 reason: `'${input.requestedVersion}' is not an exact t3 version.`,
363 });
364 }
365 const progress = createUpdateProgress();
366 progress.status("Checking for updates...");
367 const targetVersion = yield* (
368 input.requestedVersion !== undefined
369 ? Effect.succeed(input.requestedVersion)
370 : mirror === undefined
371 ? resolveNewestVersion(channel)
372 : resolveMirrorVersion(mirror, channel)
373 ).pipe(Effect.ensuring(Effect.sync(progress.finish)));
374 const targetChannel = cliReleaseChannelOf(targetVersion);
375​
376 const currentChannel = cliReleaseChannelOf(currentVersion);
377 if (targetChannel === "preview" && currentChannel !== "preview") {
378 yield* Console.log(
379 [
380 `t3@${targetVersion} is a preview build.`,
381 " Preview builds are cut by maintainers from unreleased branches to exercise the release",
382 " pipeline. They can be broken, receive no fixes, and are never offered as updates; you",
383 ` will have to switch back to ${currentChannel} yourself with \`t3 update --channel ${currentChannel} --allow-downgrade\`.`,
384 ].join("\n"),
385 );
386 if (!(process.stdin.isTTY && process.stdout.isTTY)) {
387 return yield* new CliUpdateError({
388 reason:
389 "Refusing to install a preview build without confirmation. Run this from a terminal to confirm, or pass --channel preview from an interactive shell.",
390 });
391 }
392 const confirmed = yield* Prompt.run(
393 Prompt.Confirm({ message: "Install the preview build anyway?", initial: false }),
394 ).pipe(Effect.catchTags({ QuitError: () => Effect.succeed(false) }));
395 if (!confirmed) {
396 yield* Console.log("Left as is.");
397 return;
398 }
399 }
400​
401 const status = yield* service.status;
402 // Service names are per user, so another home's unit belongs to a different install.
403 const servesThisHome =
404 status.installedBaseDir !== undefined &&
405 path.resolve(status.installedBaseDir) === path.resolve(input.baseDir);
406 const serviceInstalled = status.supported && status.installed && servesThisHome;
407 const foreground = yield* findForegroundServer({
408 serverRuntimeStatePath: input.serverRuntimeStatePath,
409 serviceInstalled,
410 });
411 const serviceVersion = serviceInstalled ? status.installedVersion : undefined;
412 const executableCurrent = targetVersion === currentVersion;
413 const restartPending = status.problems?.includes("restart-pending") === true;
414 const serviceCurrent =
415 !serviceInstalled ||
416 (serviceVersion === targetVersion &&
417 (executableCurrent ? status.current : (status.problems ?? []).length === 0));
418 const newestInstalled =
419 serviceVersion !== undefined && compareExactServiceVersions(serviceVersion, currentVersion) > 0
420 ? serviceVersion
421 : currentVersion;
422​
423 if (executableCurrent && serviceCurrent) {
424 yield* Console.log(
425 serviceVersion !== undefined
426 ? `t3 and its background service are already on ${targetVersion} (${targetChannel}).`
427 : `t3 is already on ${targetVersion} (${targetChannel}).`,
428 );
429 return;
430 }
431 if (!input.allowDowngrade && compareExactServiceVersions(targetVersion, newestInstalled) < 0) {
432 return yield* new CliUpdateError({
433 reason: `t3@${targetVersion} is older than the installed ${newestInstalled}. Pass --allow-downgrade to install it anyway.`,
434 });
435 }
436​
437 const alreadyOnDisk = yield* fs
438 .readFileString(pinnedRuntimePaths(path, input.baseDir, targetVersion, platform).sentinelPath)
439 .pipe(
440 Effect.map((sentinel) => sentinel.trim() === targetVersion),
441 Effect.orElseSucceed(() => false),
442 );
443​
444 progress.heading(
445 executableCurrent && restartPending
446 ? `The background service is still running the version before ${targetVersion} (${targetChannel}).`
447 : executableCurrent
448 ? `Updating the background service ${serviceVersion ?? "(unknown version)"} -> ${targetVersion} (${targetChannel}).`
449 : alreadyOnDisk
450 ? "Switching T3 Code"
451 : "Updating T3 Code",
452 executableCurrent
453 ? ""
454 : `${currentVersion} → ${targetVersion}${targetChannel === "stable" ? "" : ` (${targetChannel})`}`,
455 );
456 let restartService = false;
457 if (serviceInstalled && !serviceCurrent) {
458 yield* Console.log(
459 " A background service is installed for this T3 home. Restarting it interrupts anything running in it: agent turns, terminals, remote clients.",
460 );
461 if (input.assumeYes) {
462 restartService = true;
463 } else if (process.stdin.isTTY && process.stdout.isTTY) {
464 restartService = yield* Prompt.run(
465 Prompt.Confirm({
466 message: "Restart the background service once the download is verified?",
467 initial: true,
468 }),
469 ).pipe(Effect.catchTags({ QuitError: () => Effect.succeed(false) }));
470 } else {
471 yield* Console.log(
472 " Not a terminal, so the service keeps running its current version. Rerun with --yes to restart it now, or run `t3 service restart` later.",
473 );
474 }
475 }
476​
477 const runtime = yield* ensurePinnedRuntimeInstalled({
478 onProgress: progress.report,
479 baseDir: input.baseDir,
480 version: targetVersion,
481 fs,
482 path,
483 runner,
484 httpClient,
485 platform,
486 arch,
487 releaseBaseUrl: mirror?.feedUrl ?? (environment[CLI_RELEASE_BASE_URL_ENV]?.trim() || undefined),
488 requirePublishedRelease: mirror !== 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.ensuring(Effect.sync(progress.finish)),
514 Effect.catchIf(isUnpublishedRelease, () =>
515 Effect.fail(
516 new CliUpdateError({
517 reason:
518 mirror === undefined
519 ? `No release archive was published for t3@${targetVersion}.`
520 : `${mirror.organization}'s update mirror has no t3@${targetVersion} for this machine.`,
521 }),
522 ),
523 ),
524 );
525​
526 const launchedAs = (yield* HostProcess.IsExecutable) ? yield* resolveLauncherPath : undefined;
527 const repointed = yield* repointLauncher({
528 launchedAs,
529 baseDir: input.baseDir,
530 targetEntryPath: runtime.entryPath,
531 });
532​
533 // Use today's service manager for the target version. Inside the service it hands off to
534 // the target CLI, so stopping this process cannot interrupt the switch.
535 let servicePlan: BootService.BootServicePlan | undefined;
536 if (serviceInstalled && !serviceCurrent) {
537 yield* Console.log(
538 restartService
539 ? "Restarting the background service..."
540 : "Updating the background service...",
541 );
542 servicePlan = 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 }
561​
562 // A handed-off service install rewrites the unit later, while the old launcher may be stopped.
563 if (servicePlan?.handedOff !== true) {
564 // A stopped service's unit still names the launcher runtime it will start.
565 const unit = yield* fs.readFileString(status.unitPath).pipe(Effect.option);
566 yield* prunePinnedRuntimes({
567 baseDir: input.baseDir,
568 keep: [currentVersion, targetVersion],
569 references: Option.toArray(Option.flatMapNullishOr(unit, BootService.bootServiceProgramOf)),
570 });
571 }
572​
573 progress.success(`Installed T3 Code ${targetVersion}`);
574 if (Option.isSome(repointed)) {
575 yield* Console.log(" Run t3 to get started.\n");
576 } else {
577 yield* Console.log(` Run ${runtime.entryPath}\n`);
578 }
579 if (servicePlan?.handedOff === true) {
580 yield* Console.log(
581 ` Background service switching to ${targetVersion} outside this session, since this session runs inside it and disconnects when it restarts. Result: ${servicePlan.logPath}`,
582 );
583 } else if (servicePlan !== undefined && restartService) {
584 yield* Console.log(` Background service restarted on ${targetVersion}`);
585 } else if (serviceInstalled && serviceCurrent) {
586 yield* Console.log(` Background service already on ${targetVersion}`);
587 } else if (serviceInstalled) {
588 // A pending restart means the service already points at serviceVersion but runs an older one.
589 const running =
590 serviceVersion === undefined
591 ? "an unknown version"
592 : restartPending
593 ? `the version before ${serviceVersion}`
594 : serviceVersion;
595 yield* Console.log(
596 ` Background service still running ${running}. Run \`t3 service restart\` when you are ready to switch it to ${targetVersion}.`,
597 );
598 } else if (status.installed && !servesThisHome) {
599 yield* Console.log(
600 ` The background service serves ${status.installedBaseDir ?? "another T3 home"} and was left unchanged.`,
601 );
602 }
603 if (foreground !== undefined) {
604 yield* Console.log(
605 ` A server started by hand is still running at ${foreground.origin} (pid ${foreground.pid}). Stop it and start it again to pick up ${targetVersion}.`,
606 );
607 }
608});