Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(ssh): preserve external server ownership during updates #25633

ClosedViperJuice(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/25633/headopened View on GitHub

Showing 6 changed files with 52 additions and 25 deletions (loading 3).

x
0 of 6 viewed, 6 left
20 additions and 1 deletionapps/server/src/cli/sshHelper.tsModified
View file
@@ -10,6 +10,11 @@
import { Argument, Command } from "effect/cli";
​
import * as DesktopUpdateMarker from "../desktopUpdate/DesktopUpdateMarker.ts";
+import {
+ serviceLauncherIsRunning,
+ serviceLauncherLockPath,
+ stateDirOwned,
+} from "../serviceLauncher.ts";
​
const canBind = (port: number) =>
new Promise<boolean>((resolve) => {
@@ -142,7 +147,21 @@
Command.provide(DesktopUpdateMarker.layer),
​
+/** Exits 0 while a service launcher or a server holds this home, even between children. */
+const homeOwned = Command.make("home-owned", {
+ baseDir: Argument.String("base-dir"),
+}).pipe(
+ Command.withHandler(({ baseDir }) =>
+ Effect.promise(async () => {
+ const owned =
+ (await serviceLauncherIsRunning(serviceLauncherLockPath(baseDir)).catch(() => false)) ||
+ (await stateDirOwned(baseDir));
+ if (!owned) process.exitCode = 1;
+ }),
+ ),
+);