Add automatic reconnection when containers restart#1
Open
eviltik wants to merge 1 commit intojoemiller:masterfrom
Open
Add automatic reconnection when containers restart#1eviltik wants to merge 1 commit intojoemiller:masterfrom
eviltik wants to merge 1 commit intojoemiller:masterfrom
Conversation
Wrap docker logs -f in a monitoring loop that automatically reconnects when a container restarts. This prevents losing tail output when containers are stopped and restarted during monitoring. Changes: - Add infinite loop around docker logs command for each container - Check if container is running before attempting to connect - Wait 2 seconds between reconnection attempts - Maintain color and prefix formatting across reconnections Fixes issue where docker-tail would stop showing logs after a container restart, requiring manual restart of the docker-tail command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Author
|
:) |
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.
Summary
This PR adds automatic reconnection capability to
docker-tailwhen monitored containers are restarted. Previously, if a container was restarted while being monitored,docker-tailwould stop showing logs for that container, requiring a manual restart of the tool.Changes
docker logs -fcommand in an infinite monitoring loop for each containerdocker ps --format '{{.Names}}')Behavior
Before: When a container restarts, its log output stops permanently until
docker-tailis manually restarted.After: When a container restarts,
docker-tailautomatically detects it and reconnects within ~2 seconds, seamlessly resuming log output.Testing
To test this feature:
docker-tailwith one or more containersdocker restart <container>)Technical Details
Each container is now monitored in a subprocess with a loop that:
docker logs -fif the container is availableThe signal handling (
SIGINT/SIGTERM) remains unchanged and properly terminates all monitoring subprocesses whendocker-tailis stopped.Compatibility
This change is backward compatible and does not affect the command-line interface or existing functionality. It only adds resilience to container restarts.
🤖 Generated with Claude Code