Skip to content

Implement daemon mode with launchd integration#14

Merged
munezaclovis merged 4 commits intomainfrom
feat/daemon-mode
Mar 5, 2026
Merged

Implement daemon mode with launchd integration#14
munezaclovis merged 4 commits intomainfrom
feat/daemon-mode

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

Summary

  • Adds launchctl wrapper (Load, Unload, Restart, IsLoaded, GetPID) with human-readable error messages
  • Adds plist sync (NeedsSync, SyncIfNeeded) to detect and apply config drift
  • pv start --background installs plist and loads via launchd with health check polling
  • pv stop is daemon-aware: unloads launchd service or falls back to SIGTERM
  • pv restart uses launchctl kickstart for atomic daemon restart
  • pv status shows daemon/foreground mode with PID
  • pv service install/uninstall for RunAtLoad auto-start on login
  • pv log --error / pv log --daemon for daemon-specific log files
  • pv use auto-syncs plist and restarts daemon on PHP version switch
  • Documents testing strategy in CLAUDE.md

Test plan

  • 24 daemon unit tests pass (go test ./internal/daemon/ -v)
  • All internal package tests pass (go test ./internal/...)
  • E2E daemon scripts (Tasks 12-13) to be added once commands are validated on macOS runner

…mon-aware lifecycle

- Add launchctl wrapper (Load, Unload, Restart, IsLoaded, GetPID) with
  human-readable error messages
- Add plist sync (NeedsSync, SyncIfNeeded) to detect and apply plist
  changes when PHP version switches
- Add --background/--foreground flags to pv start; --background installs
  plist and loads via launchctl with health check polling
- Make pv stop daemon-aware: unloads launchd service when in daemon mode,
  falls back to PID file + SIGTERM for foreground
- Make pv restart daemon-aware: uses launchctl kickstart for atomic
  restart in daemon mode
- Enhance pv status to show daemon/foreground mode with PID
- Add pv service install/uninstall for RunAtLoad auto-start on login
- Add --error and --daemon flags to pv log for daemon log files
- Add DaemonLogPath/DaemonErrLogPath config helpers
- Wire pv use to auto-sync plist and restart daemon on PHP version switch
- Add 10 unit tests (launchctl helpers, sync detection)
pv log now shows daemon logs (pv.log) when running as daemon, caddy
logs when running in foreground — no flag needed. Added --access flag
to explicitly view FrankenPHP access logs regardless of mode.
@munezaclovis munezaclovis merged commit 80cfff7 into main Mar 5, 2026
2 checks passed
@munezaclovis munezaclovis deleted the feat/daemon-mode branch March 5, 2026 03:07
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.

1 participant