Fix service behavior after dependency failure in watch mode #596
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.
Previously, if a failure occurred in a persistent (i.e. top-level) service's dependencies, and if we were in watch mode on the 2nd or later iteration, then we completely forgot about the previously running service.
This had two similar effects, both of which could manifest as e.g. "port not available" errors:
If the dependency was eventually fixed, we would try to start the service again, even though the previous version was still running.
If the user exited wireit with Ctrl-C, we would not shut down the child process because we lost track of it.
This PR fixes these problems by transitioning to a new "started-broken" state when a failure in an already-running service's dependency occurs, which keeps a reference to the child process.
This PR also fixes some failure logging issues, where we would sometimes log the same failure multiple times, or sometimes log a failure at the very end of execution instead of as soon as it actually happens.
Fixes #568
Fixes #540
cc @SanderElias @deebloo @justinfagnani If you'd like to test out this fix early, I've published a pre-release as
wireit@0.9.2-pre.1
. If you try it, let me know how it goes!