Skip to content

Make installer gracefully stop a running instance during install - #768

Merged
twitchyliquid64 merged 2 commits into
mainfrom
tom/installer
Jul 15, 2026
Merged

Make installer gracefully stop a running instance during install#768
twitchyliquid64 merged 2 commits into
mainfrom
tom/installer

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 15, 2026

Copy link
Copy Markdown
Member
  • Installer runs min stop if it exists
  • Fixes min stop timing out and complaining if the daemon or minvmd isnt running.

Summary by CodeRabbit

  • Bug Fixes

    • min stop now exits successfully with a clear message when the daemon is already stopped.
    • Improved daemon status detection across supported platforms and daemon configurations.
  • Installer Improvements

    • Upgrades now best-effort stop the running daemon before replacing its files.
    • Stop attempts occur only when needed, at most once per installation, and do not interrupt successful upgrades if they fail.

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The CLI now probes daemon liveness before stopping, while the installer stops an existing daemon once before replacing component files. Tests and installer specifications cover lifecycle states, socket behavior, upgrade scenarios, and suppressed stop failures.

Changes

Daemon lifecycle handling

Layer / File(s) Summary
Daemon probing and stop behavior
crates/minimal/src/autospawn.rs, crates/minimal/src/lib.rs
Adds platform-specific daemon liveness probing, shared minimald socket handling, lifecycle and socket tests, and an early successful exit when stop finds no running daemon.
Installer pre-swap shutdown
scripts/install.sh, scripts/install_test.sh, docs/specs/07-spec-installer/07-spec-installer.md
Runs the installed min stop --force at most once before the first component replacement, suppresses failures and output, and adds specification and integration coverage.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant LivenessProbe
  participant Daemon
  CLI->>LivenessProbe: check daemon state
  LivenessProbe->>Daemon: inspect lifecycle or socket
  Daemon-->>LivenessProbe: liveness result
  LivenessProbe-->>CLI: running or not running
  CLI->>Daemon: request shutdown when running
Loading
sequenceDiagram
  participant Installer
  participant InstalledMin
  participant ComponentFiles
  Installer->>InstalledMin: run stop --force once
  InstalledMin-->>Installer: ignored status and suppressed output
  Installer->>ComponentFiles: replace components
Loading

Suggested reviewers: 0chroma, norrietaylor

Poem

I’m a rabbit with a daemon to tame,
Probe it gently before stopping the game.
One forced hop before files swap,
Quiet failures never make a flap.
Fresh installs bounce along—no unnecessary trap.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: the installer now stops a running daemon during installation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 15, 2026 19:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/minimal/src/autospawn.rs (1)

258-310: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Backend-selection duplication between is_daemon_running and ensure_daemon_running.

The macOS/Linux branching here mirrors ensure_daemon_running (lines 236-249) line-for-line. The doc comment even calls this out as load-bearing ("the two cannot disagree about what running means"), but that guarantee is only true as long as both copies are kept manually in sync. A future edit to one without the other would silently break the invariant.

Consider extracting a small shared backend-selection helper (e.g. an enum Backend { Minvmd, Native(PathBuf) } resolved once from use_minvmd/minimal_dir) that both ensure_daemon_running and is_daemon_running delegate to, so divergence becomes structurally impossible rather than just documented.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minimal/src/autospawn.rs` around lines 258 - 310, Extract the
duplicated backend-selection logic from ensure_daemon_running and
is_daemon_running into one shared resolver, such as a Backend enum containing
Minvmd or the resolved native socket path. Have both functions use this resolver
while preserving the existing platform-specific behavior and probe semantics, so
backend selection cannot diverge between the two call paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/minimal/src/autospawn.rs`:
- Around line 258-310: Extract the duplicated backend-selection logic from
ensure_daemon_running and is_daemon_running into one shared resolver, such as a
Backend enum containing Minvmd or the resolved native socket path. Have both
functions use this resolver while preserving the existing platform-specific
behavior and probe semantics, so backend selection cannot diverge between the
two call paths.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 42c29ba8-b231-472b-b965-ab35d3705ea1

📥 Commits

Reviewing files that changed from the base of the PR and between 091d736 and 8cea309.

📒 Files selected for processing (5)
  • crates/minimal/src/autospawn.rs
  • crates/minimal/src/lib.rs
  • docs/specs/07-spec-installer/07-spec-installer.md
  • scripts/install.sh
  • scripts/install_test.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants