File unexpectedly closes during tailing process
asra-eero opened this issue · 0 comments
asra-eero commented
Describe the bug
We have a file that we're tailing where we're also interested in the file offset location. However, when we do t.Tell()
, we sometimes run into the exception "err":"seek <filename>: file already closed"
Code:
t, err := tail.TailFile(
path,
tail.Config{
Follow: true,
ReOpen: true,
})
for line := range t.Lines {
// Fetch the current offset in the tailed file
offset, err := t.Tell()
// consume data
}
Has anyone else seen a similar issue with the file being closed? We've kind of solved this by adding a small wait and a retry in the t.Tell()
function call, and that's resolved the issue, but we'd like to understand if this is a bug in the underlying tailing code where it's prematurely closing files.
System information
- tail version: v1.4.8
- OS: Ubuntu: 18.04