Skip to content

Restart stale daemons after agent-cdp upgrades#7

Merged
V3RON merged 1 commit intomasterfrom
fix/daemon-version-restart
May 5, 2026
Merged

Restart stale daemons after agent-cdp upgrades#7
V3RON merged 1 commit intomasterfrom
fix/daemon-version-restart

Conversation

@V3RON
Copy link
Copy Markdown
Contributor

@V3RON V3RON commented May 5, 2026

agent-cdp now detects when the running daemon was started by a different package version and restarts it automatically before handling daemon-backed commands. Users who upgrade the CLI no longer need to manually kill lingering older daemons to get status, target selection, or capture workflows working reliably again.

Summary

  • store the package version in daemon state and use it as the daemon compatibility signal
  • restart stale or versionless daemons from the shared bootstrap path, including the status command
  • add focused daemon-client tests for reuse, restart-on-mismatch, and restart-on-legacy-state behavior

Backward Compatibility

  • Existing commands and flags remain unchanged.
  • Default CLI output remains unchanged.
  • Older daemon.json files that do not include a version are treated as stale and trigger a restart automatically.
  • Daemon lifecycle stays the same from a user perspective, except stale daemons are now refreshed automatically after upgrades.

Risks

  • Restarting an incompatible daemon depends on the old process exiting promptly after SIGTERM; if it ignores shutdown, daemon-backed commands will now fail instead of silently talking to stale code.
  • status now starts or refreshes the daemon for consistency, which changes its previous behavior of failing when no daemon metadata existed.
  • The version source is read from the package manifest at runtime; packaging or distribution changes that move that manifest unexpectedly could affect startup.

Manual testing

  • Setup: install or build one version of agent-cdp, start the daemon with agent-cdp start, then update the package to a newer version without manually stopping the daemon.
  • Run agent-cdp status.
  • Verify the command succeeds and reports status from a freshly started daemon instead of talking to the lingering older process.
  • Run another daemon-backed command such as agent-cdp target list.
  • Verify it also succeeds without requiring a manual agent-cdp stop first.
  • Run agent-cdp stop and verify the daemon still shuts down cleanly.

Closes #6.

@V3RON V3RON merged commit 5979030 into master May 5, 2026
4 checks passed
@V3RON V3RON deleted the fix/daemon-version-restart branch May 5, 2026 12:20
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.

Restart stale daemon when CLI and daemon versions differ

1 participant