Skip to content

fix(service): do not auto-enable systemd service on install#5693

Open
darrenzeng2025 wants to merge 3 commits intozeroclaw-labs:masterfrom
darrenzeng2025:fix/5628-systemd-service-no-auto-start
Open

fix(service): do not auto-enable systemd service on install#5693
darrenzeng2025 wants to merge 3 commits intozeroclaw-labs:masterfrom
darrenzeng2025:fix/5628-systemd-service-no-auto-start

Conversation

@darrenzeng2025
Copy link
Copy Markdown
Contributor

@darrenzeng2025 darrenzeng2025 commented Apr 13, 2026

Summary

  • Base branch target: master
  • Problem: zeroclaw service install previously ran systemctl --user enable, causing the daemon to auto-start on every login/boot.
  • Why it matters: This created port conflicts when users later tried to run zeroclaw daemon manually, and violated the expectation that "install" does not imply "auto-start".
  • What changed: Removed the enable step from zeroclaw service install; the service remains installed but inactive until the user explicitly runs zeroclaw service start.
  • What did not change: The start/stop/uninstall commands or any service-unit template content.

Label Snapshot

  • Risk label: risk: low
  • Scope labels: service
  • Change type: bug
  • Primary scope: service

Linked Issue

Validation Evidence

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test
  • Evidence provided: code review, logic trace
  • Intentionally skipped: local cargo build could not be fully validated due to a pre-existing toolchain issue (libsqlite3-sys compilation failure on this host). The change is isolated to the service-install command path.

Compatibility / Migration

  • Backward compatible? Yes (behavior change, not API break)
  • Config/env changes? No
  • Migration needed? No
  • Note: Users who relied on auto-start after install will now need to run zeroclaw service start explicitly.

Human Verification

  • Verified scenarios: Traced the install command flow to confirm enable is removed and start is unaffected.
  • Edge cases checked: N/A
  • What was not verified: Full cargo test run due to local libsqlite3-sys build failure.

Side Effects / Blast Radius

  • Affected subsystems: zeroclaw service install behavior.
  • Potential unintended effects: Users expecting auto-enable may notice the service is not active after install.
  • Guardrails: The CLI already prints next-step guidance after install.

Rollback Plan

  • Fast rollback: git revert the single commit on this branch.
  • Feature flags: None.
  • Observable failure symptoms: Users report the service is not enabled after install.

Risks and Mitigations

None.

zeroclaw service install previously ran systemctl --user enable,
causing the daemon to auto-start on every login/boot and creating
port conflicts when users later tried to run zeroclaw daemon
manually.

Removing the enable step keeps the service installed but inactive
until the user explicitly runs zeroclaw service start.

Fixes zeroclaw-labs#5628
@theonlyhennygod
Copy link
Copy Markdown
Collaborator

Hi @darrenzeng2025 — this is a service behavior change so we need more context. Please update to follow our PR template — specifically Summary, Validation Evidence, Compatibility/Migration (since this changes systemd behavior), and Rollback Plan. Thanks!

@theonlyhennygod theonlyhennygod added the service Auto scope: src/service/** changed. label Apr 14, 2026
@github-actions github-actions bot removed the service Auto scope: src/service/** changed. label Apr 14, 2026
@singlerider singlerider added the risk: high Auto risk: security/runtime/gateway/tools/workflows. label Apr 16, 2026
@JordanTheJet
Copy link
Copy Markdown
Collaborator

Reviewer Verdict: Needs author action

0.7.0 Relevance Check

  • File crates/zeroclaw-runtime/src/service/mod.rs exists on master.
  • Line systemctl --user enable zeroclaw.service still present at master line 752.
  • PR is still relevant post-v0.7.0 refactor.

Comprehension Summary

Removes the systemctl --user enable zeroclaw.service call from install_linux_systemd so that zeroclaw service install no longer wires the daemon to start automatically on user login. Closes #5628 by addressing option (b) from the issue (install does not imply auto-start).

Security Assessment

service/mod.rs is security-sensitive (touches systemd unit installation, runs as user). The change strictly reduces surface area — removing one shell-out — so no new injection or privilege risk. No unit-template content changed.

Findings

[suggestion] Cross-platform inconsistency. This PR only removes auto-enable for systemd. Other init systems still auto-start at boot/login:

  • OpenRC: install_linux_openrc still calls rc-update add zeroclaw default (line ~1282) — the OpenRC equivalent of systemctl enable.
  • macOS: install_macos writes a plist with RunAtLoad=true and KeepAlive=true, so once service start runs launchctl load -w, it auto-launches at login.
  • Windows: install_windows registers a scheduled task with /SC ONLOGON.

After this change, systemd users get "install ≠ auto-start", but OpenRC/macOS/Windows users still get auto-start. Either align the other paths with the new contract, or scope the PR title/body to clarify it is systemd-only by design.

[question] No path for users who want auto-start. start_linux for systemd only runs systemctl --user start, never enable (or enable --now). After this PR, there is no CLI flag (e.g., --enable) and no documented command for users who do want the service to come back after reboot. Issue #5628 explicitly listed this as an alternative ("requiring an explicit zeroclaw service start"), but did not foreclose offering an opt-in. Should service install --enable or a follow-up doc note be added?

[nit] PR body label mismatch. Body's "Label Snapshot" claims risk: low; the auto-applied label is risk: high. Update one or the other so reviewers can trust the snapshot.

[nit] Validation evidence. Body lists cargo fmt/clippy/test but acknowledges the local build was blocked by libsqlite3-sys. Acceptable for a one-line removal, but call out that none of the three commands actually executed to completion.

Rollback Story

Single-line revert; clean. No state migration. Acceptable.

@singlerider singlerider added needs-author-action Author action required before merge size: XS Auto size: <=80 non-doc changed lines. labels Apr 17, 2026
Copy link
Copy Markdown
Collaborator

@singlerider singlerider left a comment

Choose a reason for hiding this comment

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

Comprehension Summary

Removes systemctl --user enable zeroclaw.service from install_linux_systemd so that zeroclaw service install no longer auto-starts the daemon on login. Blast radius: service install behavior, systemd path only. Closes #5628.

Template Issues

  • Label mismatch: PR body claims risk: low; the applied label is risk: high. service/mod.rs is in the runtime crate — risk: high is correct. Update the Label Snapshot section.
  • Validation evidence: Body lists cargo fmt/clippy/test but acknowledges the local build was blocked by libsqlite3-sys. State explicitly that none of the three commands ran to completion rather than listing them as run.

Security / Performance

Strictly reduces surface area — removes one shell-out. No new injection or privilege risk. No unit-template content changed.


fs::write(&file, unit)?;
let _ = run_checked(Command::new("systemctl").args(["--user", "daemon-reload"]));
let _ = run_checked(Command::new("systemctl").args(["--user", "enable", "zeroclaw.service"]));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[blocking] This removes enable for systemd only. Three other init paths still auto-start on install:

  • install_linux_openrc calls rc-update add zeroclaw default — the OpenRC equivalent of systemctl enable
  • install_macos writes a plist with RunAtLoad=true + KeepAlive=true
  • install_windows registers a scheduled task with /SC ONLOGON

After this change, systemd users get "install ≠ auto-start" while all other platforms still auto-start. Either align the other init paths to the same contract or explicitly scope this PR as systemd-only in the title, body, and a code comment here.

[question] There is no CLI path for users who want the service to survive a reboot. start_linux_systemd only runs systemctl --user start, never enable. Consider adding zeroclaw service install --enable (opt-in) or at minimum documenting the manual workaround (systemctl --user enable zeroclaw.service) in the post-install output.

@github-project-automation github-project-automation bot moved this from Backlog to Needs Changes in ZeroClaw Project Board Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-author-action Author action required before merge risk: high Auto risk: security/runtime/gateway/tools/workflows. size: XS Auto size: <=80 non-doc changed lines.

Projects

Status: Needs Changes

Development

Successfully merging this pull request may close these issues.

[Bug]: Daemon service auto-starts on boot, causes port conflict for manual runs

4 participants