Skip to content

Add Linux systemd daemon support#19

Merged
CalebisGross merged 3 commits intomainfrom
feat/linux-systemd-daemon
Feb 28, 2026
Merged

Add Linux systemd daemon support#19
CalebisGross merged 3 commits intomainfrom
feat/linux-systemd-daemon

Conversation

@CalebisGross
Copy link
Copy Markdown
Collaborator

Summary

  • Extracts hardcoded macOS launchctl calls into a ServiceManager interface with build-tagged implementations per platform
  • Adds Linux systemd user service support (systemctl --user) for install, uninstall, start, stop, and status
  • Adds unsupported-platform stub so the code compiles cleanly on Windows
  • Preserves PID-file fallback for systems without a service manager installed

Files Changed

File What
internal/daemon/service.go New ServiceManager interface (7 methods)
internal/daemon/service_darwin.go macOS launchd — extracted existing code, identical logic
internal/daemon/service_linux.go Linux systemd — new systemctl --user implementation
internal/daemon/service_other.go Stub for unsupported platforms
internal/daemon/daemon.go Removed 48 lines of hardcoded launchctl functions
cmd/mnemonic/main.go Commands use ServiceManager interface; plist template moved to darwin file
.claude/rules/code-quality.md New rule: scope discipline, change safety
.claude/rules/platform-safety.md New rule: never break existing platforms

Test plan

  • go build succeeds on Linux (compiles service_linux.go)
  • go vet passes
  • gofmt clean on all changed files
  • All existing tests pass (go test ./...)
  • Binary runs: mnemonic version, mnemonic help produce correct output
  • Help text updated: "Install as system service" (not "macOS LaunchAgent")
  • Verified macOS launchd code is line-for-line identical to the extracted original
  • Manual test on macOS: mnemonic install / mnemonic start / mnemonic stop / mnemonic uninstall
  • Manual test on Linux: mnemonic install creates systemd unit file

Closes #1, #2, #15

🤖 Generated with Claude Code

CalebisGross and others added 3 commits February 27, 2026 20:55
Extract hardcoded macOS launchctl calls into a ServiceManager interface
with build-tagged implementations: launchd (darwin), systemd (linux),
and a stub (other platforms). The install/uninstall/start/stop/status
commands now work on both macOS and Linux via systemctl --user.

Closes #1, closes #2, closes #15

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CalebisGross CalebisGross merged commit cd1d115 into main Feb 28, 2026
3 checks passed
@CalebisGross CalebisGross deleted the feat/linux-systemd-daemon branch March 11, 2026 05:13
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.

Daemon uses launchctl unconditionally — crashes on Linux

1 participant