Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.
TypeScript browser-shellcontrol-planefile-managerhomelabmobile-firstnextjsptyreactself-hostedserver-managementshadcn-uisysadmintailwindcssterminaltypescriptvpsweb-desktopweb-terminal
fix(install): restore service after pre-mutation abort
Abdurrahman Fakhrula2a2c82a8d03
diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 11747547..6abd34c4 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -13,6 +13,7 @@ this is the *what*, and it is what Settings → About shows as “What's new”.**Fixed**+- `install` restore service after pre-mutation abort- `runtime` close update authority and stop races- `runtime` preserve installer and env lifecycles- `runtime` serialize deploy and service startsdiff --git a/scripts/install-core.sh b/scripts/install-core.shold mode 100755new mode 100644index f44500ad..9ede3a43--- a/scripts/install-core.sh+++ b/scripts/install-core.sh@@ -413,8 +413,9 @@ fiINSTALL_PHASE=runtime-safety# ---- freeze every runtime that can read this checkout before dependency/build mutation -----# The lifecycle remains open through service refresh. On failure, EXIT releases locks-# but intentionally keeps gateway restore intent so a broken build is never served.+# The lifecycle remains open through service refresh. A pre-mutation abort restores the+# known-good service/fallbacks; after mutation starts EXIT preserves recovery intent and+# never serves the possibly changed tree.# shellcheck source=scripts/lib/install-runtime-lifecycle.sh. "$DIR/scripts/lib/install-runtime-lifecycle.sh"trap install_runtime_lifecycle_cleanup EXIT@@ -424,6 +425,7 @@ install_runtime_lifecycle_beginINSTALL_PHASE=dependencies# ---- deps (compiles node-pty) ----info "installing dependencies…"+install_runtime_lifecycle_mark_mutation_startedbun install --frozen-lockfile || bun installINSTALL_PHASE=configurationdiff --git a/scripts/install-runtime-abort-recovery.test.ts b/scripts/install-runtime-abort-recovery.test.tsnew file mode 100644index 00000000..578ec583--- /dev/null+++ b/scripts/install-runtime-abort-recovery.test.ts@@ -0,0 +1,53 @@+import { spawnSync } from "node:child_process";+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterEach, describe, expect, it } from "vitest";++const HELPER = path.join(process.cwd(), "scripts/lib/install-runtime-lifecycle.sh");+const roots: string[] = [];++function runCleanup(mutationStarted: boolean) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "mso-install-abort-"));+ roots.push(root);+ const capture = path.join(root, "capture");+ const script = `+set -euo pipefail+DIR=/tmp; PORT=4005; DO_SERVICE=1; SERVICE=mso.service+die(){ echo "die:$*" >&2; exit 1; }+sudo_do(){ printf 'sudo %s\n' "$*" >> ${JSON.stringify(capture)}; }+systemd_ready(){ return 0; }+. ${JSON.stringify(HELPER)}+runtime_exclusion_release(){ echo release-runtime >> ${JSON.stringify(capture)}; }+update_gateway_restore_all(){ echo restore-fallbacks >> ${JSON.stringify(capture)}; }+update_lock_release(){ echo release-update >> ${JSON.stringify(capture)}; }+INSTALL_RUNTIME_LIFECYCLE=1+INSTALL_RUNTIME_SERVICE_STOPPED=1+${mutationStarted ? "install_runtime_lifecycle_mark_mutation_started" : ""}+install_runtime_lifecycle_cleanup+`;+ const out = spawnSync("bash", ["-c", script], { encoding: "utf8" });+ return { out, calls: fs.existsSync(capture) ? fs.readFileSync(capture, "utf8") : "" };+}++afterEach(() => { for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true }); });++describe("installer abort recovery", () => {+ it("restores the known-good service and fallbacks when aborting before mutation", () => {+ const { out, calls } = runCleanup(false);+ expect(out.status).toBe(0);+ expect(calls).toContain("release-runtime");+ expect(calls).toContain("sudo systemctl start mso.service");+ expect(calls).toContain("restore-fallbacks");+ expect(calls).toContain("release-update");+ });++ it("does not restart any runtime after installer mutation has started", () => {+ const { out, calls } = runCleanup(true);+ expect(out.status).toBe(0);+ expect(calls).toContain("release-runtime");+ expect(calls).toContain("release-update");+ expect(calls).not.toContain("systemctl start mso.service");+ expect(calls).not.toContain("restore-fallbacks");+ });+});diff --git a/scripts/lib/install-runtime-lifecycle.sh b/scripts/lib/install-runtime-lifecycle.shindex 277a2509..e5e04724 100644--- a/scripts/lib/install-runtime-lifecycle.sh+++ b/scripts/lib/install-runtime-lifecycle.sh@@ -5,6 +5,7 @@INSTALL_RUNTIME_LIFECYCLE=0INSTALL_RUNTIME_SERVICE_STOPPED=0+INSTALL_RUNTIME_MUTATION_STARTED=0install_runtime_lifecycle_init() {ROOT="$DIR"@@ -25,8 +26,30 @@ install_runtime_lifecycle_init() {install_runtime_lifecycle_cleanup() {[ "$INSTALL_RUNTIME_LIFECYCLE" = 1 ] || return 0++ # Before the first dependency/build mutation, the old checkout is still safe to+ # serve. If begin() stopped an active service and then a validation/signal aborts,+ # restore that known-good service instead of leaving the machine offline. Once+ # mutation starts we deliberately do NOT restart anything from the changed tree.runtime_exclusion_release >/dev/null 2>&1 || true+ if [ "$INSTALL_RUNTIME_MUTATION_STARTED" = 0 ]; then+ if [ "$INSTALL_RUNTIME_SERVICE_STOPPED" = 1 ]; then+ sudo_do systemctl start "$SERVICE" >/dev/null 2>&1 \+ || printf 'mso installer: warning: could not restore %s after pre-mutation abort\n' "$SERVICE" >&2+ fi+ if ! (update_gateway_restore_all) >/dev/null 2>&1; then+ printf 'mso installer: warning: could not restore fallback runtimes after pre-mutation abort\n' >&2+ fi+ fiupdate_lock_release >/dev/null 2>&1 || true+ INSTALL_RUNTIME_LIFECYCLE=0+ INSTALL_RUNTIME_SERVICE_STOPPED=0+ INSTALL_RUNTIME_MUTATION_STARTED=0+}++install_runtime_lifecycle_mark_mutation_started() {+ [ "$INSTALL_RUNTIME_LIFECYCLE" = 1 ] || die "runtime lifecycle must be active before installer mutation"+ INSTALL_RUNTIME_MUTATION_STARTED=1}install_runtime_active_service_preflight() {