Skip to content

Auto-start Colima and recover services on daemon boot#49

Merged
munezaclovis merged 2 commits intomainfrom
feat/colima-daemon-autostart
Mar 27, 2026
Merged

Auto-start Colima and recover services on daemon boot#49
munezaclovis merged 2 commits intomainfrom
feat/colima-daemon-autostart

Conversation

@munezaclovis
Copy link
Copy Markdown
Contributor

Summary

When the pv daemon starts (e.g. after macOS reboot via launchd), it now automatically boots the Colima VM and recovers stopped service containers — so services come back without user intervention.

Before: Daemon starts DNS + FrankenPHP. Colima stays down. Services dead until user runs pv service:start.

After: Daemon starts DNS + FrankenPHP immediately, then boots Colima in the background and recovers containers. Services come up ~15s after daemon start.

  • Only triggers when Colima is installed AND services are registered
  • Runs in a background goroutine (doesn't block DNS/PHP startup)
  • Retries once after 10s if Colima fails
  • Logs warnings on failure, daemon keeps running for PHP/DNS

Test plan

  • go test ./... passes
  • go vet ./... clean
  • Manual: reboot Mac, verify services come back automatically
  • Manual: pv service:add redis, restart daemon, verify redis recovers
  • Manual: stop Colima manually, restart daemon, verify it boots Colima

When the daemon starts and services are registered, launch a
background goroutine that boots the Colima VM and recovers
stopped service containers. This ensures services come back
automatically after a macOS reboot without user intervention.

- Runs in background so DNS + FrankenPHP start immediately
- Only triggers when Colima is installed AND services exist
- Retries once after 10s if Colima fails to start
- Logs warnings on failure, daemon keeps running for PHP/DNS
…ervation

- Add cancellable context so goroutine stops on daemon shutdown
- Use ctx in sleep (select on timer vs ctx.Done) and all Docker calls
- Check ctx.Err() between steps to bail early on shutdown
- Reload registry inside goroutine instead of sharing stale pointer
- Preserve original error in retry message so both are visible
- Add descriptive "Starting Colima VM" message on auto-start
@munezaclovis munezaclovis merged commit 13db951 into main Mar 27, 2026
1 check failed
@munezaclovis munezaclovis deleted the feat/colima-daemon-autostart branch March 27, 2026 01:53
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