Skip to content

Reconcile-based server manager for dynamic PHP version switching#52

Merged
munezaclovis merged 9 commits intomainfrom
feat/server-reconcile
Mar 27, 2026
Merged

Reconcile-based server manager for dynamic PHP version switching#52
munezaclovis merged 9 commits intomainfrom
feat/server-reconcile

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

Summary

Implements a reconcile architecture so the daemon can dynamically start/stop secondary FrankenPHP instances when PHP versions change without requiring daemon restarts.

New: ServerManager + SIGHUP protocol

  • ServerManager owns main + secondary FrankenPHP instances with Reconcile()
  • CLI commands send SIGHUP to daemon via SignalDaemon()
  • Daemon event loop catches SIGHUP and calls Reconcile()

Simplified CLI commands

  • pv link: 15 lines of restart logic replaced with SignalDaemon()
  • pv unlink: 23 lines of orphan detection replaced with SignalDaemon()
  • pv restart: SIGHUP in foreground, full restart in daemon mode
  • pv php:use: always full daemon restart (main binary changes)
  • pv service:add/remove/destroy: now signal daemon after config changes

Test plan

  • go test ./... passes
  • go vet ./... clean
  • Manual: link project with non-global PHP, verify secondary starts
  • Manual: change pv.yml, verify no 502
  • Manual: unlink project, verify orphaned secondary stops

ServerManager owns all FrankenPHP instances and provides a single
Reconcile() method that reads configs from disk, diffs running
instances against what's needed, and starts/stops accordingly.
Handles crashed instance detection and restart.
Replace inline secondary management with manager.Reconcile().
Add SIGHUP handler to event loop for CLI-triggered reconcile.
Simplify waitForEvent. Remove ReconfigureServer().
Callers in cmd/ updated in next commit.
- pv link: 15 lines of restart logic → SignalDaemon()
- pv unlink: 23 lines of orphan detection → SignalDaemon()
- pv restart: SIGHUP in foreground, full restart in daemon mode
- pv php:use: always full daemon restart (main binary changes)
Service add/remove/destroy generate service site configs but never
told FrankenPHP to reload. Now send SIGHUP so the daemon reconciles
and the main FrankenPHP picks up new service routes.
- Reconcile() now returns accumulated errors when secondary instances
  fail to start (previously returned nil hiding partial failures)
- SIGHUP handler wraps Reconcile() in recover() so a panic doesn't
  crash the entire daemon event loop
@munezaclovis munezaclovis merged commit f3e0d9e into main Mar 27, 2026
1 check failed
@munezaclovis munezaclovis deleted the feat/server-reconcile branch March 27, 2026 06:06
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