feat: start mocks detached and target stop by mock ID#4
Open
outofcoffee wants to merge 1 commit into
Open
Conversation
Rewrite start-mocks to use 'imposter up --detach=healthy', so the CLI backgrounds the mock and waits for the healthcheck itself, replacing the manual curl loop. Add a mock-id-file input that writes the started mock ID via --id-file. Add mock-id and mock-id-file inputs to stop-mocks so a single mock can be stopped by ID or from an ID file, falling back to stopping all mocks. Deprecate the now-unused auto-restart, max-attempts and retry-interval inputs, which no longer have any effect with the detached start.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Start mocks detached (waiting for the healthcheck) and stop a specific mock by ID, with a shared ID file linking the two.
Summary
start-mocksnow runsimposter up --detach=healthy: the CLI backgrounds the mock and waits for the healthcheck itself, replacing the hand-rolled curl polling loop.mock-id-fileinput onstart-mockswrites the started mock's ID (via--id-file) so it can be torn down precisely later.stop-mocksgainsmock-idandmock-id-fileinputs to stop a single mock by ID or from an ID file; with neither set it still stops every managed mock (--all).auto-restart,max-attemptsandretry-intervalinputs onstart-mocks(they have no effect under the detached start), warning if they are set.Implementation details
--detachand--id-fileflags.--detach=healthyblocks until the healthcheck passes, so the step completes only when the mock is ready — and the detached process survives the step, which is more robust than the previous&backgrounding (notably for non-docker engines).--detachis incompatible with auto-restart in the CLI (the config-dir watcher lives in the foreground process, which exits once the mock is backgrounded), which is why those polling/restart inputs are deprecated rather than rewired.${{ }}interpolation, to avoid script injection.