feat(cli): restart command #839
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Overview
Greptile Summary
This PR adds a new
restartcommand to the Helix CLI that stops and starts database instances (both local Docker-based and cloud Fly.io instances). The implementation follows existing patterns fromstartandstopcommands with proper error handling, progress tracking, and instance validation.Key changes:
restart_instance()method usingdocker compose restartHELIX_DATA_DIRto/datafor consistent container pathsThe restart command properly validates instance existence, checks for build artifacts, and handles both Docker/Podman runtimes. Cloud restart uses stop+start sequence via FlyManager. Test infrastructure includes isolated temp directories via
HELIX_CACHE_DIRoverride.Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant CLI as restart::run() participant Project as ProjectContext participant Docker as DockerManager participant Fly as FlyManager participant Container as Docker/Podman User->>CLI: helix restart [instance] CLI->>Project: find_and_load() Project-->>CLI: project context alt No instance provided & non-interactive CLI->>CLI: list_instances() CLI-->>User: Error: Available instances end CLI->>Project: get_instance(name) Project-->>CLI: instance_config alt Local Instance CLI->>Docker: new(project) CLI->>Docker: check_runtime_available() Docker-->>CLI: runtime OK CLI->>CLI: Check docker-compose.yml exists alt Compose file missing CLI-->>User: Error: Not built yet end CLI->>Docker: restart_instance(name) Docker->>Container: docker compose restart Container-->>Docker: success Docker-->>CLI: OK CLI-->>User: Container restarted else Cloud Instance (Fly.io) CLI->>CLI: Validate cluster_id CLI->>Fly: new(project, auth_type) Fly-->>CLI: fly manager CLI->>Fly: stop_instance(name) Fly->>Fly: flyctl scale count 0 Fly-->>CLI: stopped CLI->>Fly: start_instance(name) Fly->>Fly: flyctl scale count 1 Fly-->>CLI: started CLI-->>User: Cloud instance restarted end