Skip to content

Refactor watcher, status, start, stop into controller/worker pattern#145

Merged
jonathonbyrdziak merged 1 commit intomasterfrom
refactor/controller-worker-pattern
Mar 23, 2026
Merged

Refactor watcher, status, start, stop into controller/worker pattern#145
jonathonbyrdziak merged 1 commit intomasterfrom
refactor/controller-worker-pattern

Conversation

@jonathonbyrdziak
Copy link
Copy Markdown
Contributor

Summary

  • ReleaseWatcher class: Extracted the 277-line procedural while(true) loop from bin/release-watcher.php into src/Helpers/ReleaseWatcher.php with proper controller/worker separation. Strategy handlers (handleReleaseStrategy, handleBlueGreenStrategy, handleBranchStrategy) are isolated workers. Shared logic (fetchAndVerifyTag, initAndCheckoutRelease, buildAndHealthCheck) is extracted into reusable workers.
  • ProtocolStatus: Extracted the monolithic execute() into section renderers (renderNodeInfo, renderServices, renderDocker, renderConfiguration, renderSecurity, renderDisk, renderSummary) with a buildContext() that reads all state once.
  • ProtocolStart: Split provisionInfrastructure() into 4 focused workers: provisionGitHubCredentials, provisionConfigRepo, provisionSlaveWatchers, provisionCrontab.
  • ProtocolStop: Split stopContainers() into 4 focused workers: stopSimpleContainers, stopReleaseContainers, stopTrackedReleaseDirs, sweepOrphanReleases.

Test plan

  • protocol start from a project dir starts containers (strategy=none)
  • protocol stop from a project dir stops containers
  • protocol status displays all dashboard sections correctly
  • On server: release watcher detects new version and deploys correctly
  • On server: protocol start --dir=/releases/v1.0.x/ starts the correct version
  • On server: protocol stop --dir=/releases/v1.0.x/ stops just that release

🤖 Generated with Claude Code

- Extract release-watcher.php into ReleaseWatcher class with strategy
  handler methods instead of a 277-line if/else chain
- Split ProtocolStatus execute() into section renderers (renderNodeInfo,
  renderServices, renderDocker, renderConfiguration, renderSecurity, etc.)
- Split provisionInfrastructure() into provisionGitHubCredentials,
  provisionConfigRepo, provisionSlaveWatchers, provisionCrontab
- Split stopContainers() into stopSimpleContainers, stopReleaseContainers,
  stopTrackedReleaseDirs, sweepOrphanReleases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jonathonbyrdziak jonathonbyrdziak merged commit afbde64 into master Mar 23, 2026
5 of 8 checks passed
@jonathonbyrdziak jonathonbyrdziak deleted the refactor/controller-worker-pattern branch March 23, 2026 21:05
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