Checking for creation of logfile, without CPU spin, but bail if too many errors #113
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.
Commit 4c86ed7 fixed the CPU spinning issue, but it also causes dockerize to bail out immediately if a logfile hasn't been created yet by the program to be run when the tail thread goes to look for it. This race condition has broken a lot of my images built using dockerize, and I imagine that it may effect others.
This PR uses time.Sleep() to have the tail thread sleep 2 seconds before retrying, and allows a certain number of retries before bailing out. The number of retries is set for 30, which is gives about a minute for a program to initialize and get its logs going - I'm happy to set it lower if a minute seems too long.
Tailing named pipes is still supported, but the code assumes that if this is a named pipe, mkfifo has already been called before dockerize gets executed.