Skip to content

Fix daemon and server error handling#37

Merged
munezaclovis merged 4 commits intomainfrom
fix/daemon-server-error-handling
Mar 10, 2026
Merged

Fix daemon and server error handling#37
munezaclovis merged 4 commits intomainfrom
fix/daemon-server-error-handling

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

Summary

  • Launchctl commands now include Go error + command output in error messages for better debugging
  • daemon:enable handles already-loaded service gracefully (updates plist and restarts)
  • Server waitForEvent returns actual errors instead of always nil on child exit
  • All server output directed to stderr (was incorrectly using stdout)
  • DNS WriteMsg errors, signal cleanup, PID removal errors, and watcher version resolution errors all properly logged

Test plan

  • go build ./... passes
  • go test ./... passes
  • pv daemon:enable when daemon already running updates and restarts cleanly
  • pv start --foreground logs to stderr, not stdout
  • Killing FrankenPHP child causes server to exit with descriptive error

- Launchctl Load/Unload/Restart now include Go error and command output
  in error messages for better debugging
- daemon:enable handles already-loaded service by updating plist and
  restarting instead of failing
- Server waitForEvent returns actual errors instead of always nil
- DNS WriteMsg errors are logged to stderr
- All server output goes to stderr (was using stdout)
- Signal cleanup via defer signal.Stop
- DNS shutdown errors logged on server exit
- removePID logs errors instead of silently discarding
- Watcher logs ResolveVersion errors before falling back to global PHP
When linking a project that requires a secondary FrankenPHP instance
(non-default PHP version) while the daemon is running, automatically
restart the daemon to spawn the needed secondary process. Previously,
ReconfigureServer only reloaded the main Caddy config, leaving the
secondary FrankenPHP unstarted and causing 502 errors.

Also fix e2e start-curl.sh to disable the daemon before starting in
foreground mode, since pv install now auto-enables the daemon.
When unlinking the last project using a non-default PHP version, restart
the daemon to stop the orphaned secondary FrankenPHP process. Uses
caddy.ActiveVersions to check if the version is still needed.
- Guard against panic on empty DNS question slice in WriteMsg error log
- Fix import ordering in link.go (daemon before detection)
- Log settings load failure in unlink.go instead of silently discarding
- Use ui.Fail instead of ui.Subtle for daemon restart failures
- Unload daemon before reinstalling plist in enable.go (ensures new
  plist is picked up instead of cached version)
- Fix ReconfigureServer comment: only reloads, does not restart
- Fix merged channel comment: only receives from secondaries
- Foreground mode hints now say "pv stop && pv start" since pv restart
  only reloads and cannot manage secondary FrankenPHP processes
@munezaclovis munezaclovis merged commit 9da36d1 into main Mar 10, 2026
1 check passed
@munezaclovis munezaclovis deleted the fix/daemon-server-error-handling branch March 10, 2026 08:39
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