Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,17 @@ func tailFile(ctx context.Context, file string, poll bool, dest *os.File) {
return
// get the next log line and echo it out
case line := <-t.Lines:
if t.Err() != nil {
log.Printf("Warning: unable to tail %s: %s", file, t.Err())
errCount++
if errCount > 30 {
log.Fatalf("Logged %d consecutive errors while tailing. Exiting", errCount)
if line == nil {
// Check if there's an actual error
if err := t.Err(); err != nil {
log.Printf("Warning: unable to tail %s: %s", file, err)
errCount++
if errCount > 30 {
log.Fatalf("Logged %d consecutive errors while tailing. Exiting", errCount)
}
time.Sleep(2 * time.Second) // Sleep for 2 seconds before retrying
continue
}
time.Sleep(2 * time.Second) // Sleep for 2 seconds before retrying
} else if line == nil {
return
} else {
fmt.Fprintln(dest, line.Text)
Expand Down