Merge branch 'namedpipe' of https://github.com/42wim/tail into 42wim-namedpipe
This commit is contained in:
commit
71a3d44347
8
tail.go
8
tail.go
|
@ -58,6 +58,7 @@ type Config struct {
|
||||||
ReOpen bool // Reopen recreated files (tail -F)
|
ReOpen bool // Reopen recreated files (tail -F)
|
||||||
MustExist bool // Fail early if the file does not exist
|
MustExist bool // Fail early if the file does not exist
|
||||||
Poll bool // Poll for file changes instead of using inotify
|
Poll bool // Poll for file changes instead of using inotify
|
||||||
|
Pipe bool // Is a named pipe (mkfifo)
|
||||||
RateLimiter *ratelimiter.LeakyBucket
|
RateLimiter *ratelimiter.LeakyBucket
|
||||||
|
|
||||||
// Generic IO
|
// Generic IO
|
||||||
|
@ -223,14 +224,19 @@ func (tail *Tail) tailFileSync() {
|
||||||
|
|
||||||
tail.openReader()
|
tail.openReader()
|
||||||
|
|
||||||
|
var offset int64 = 0
|
||||||
|
var err error
|
||||||
// Read line by line.
|
// Read line by line.
|
||||||
for {
|
for {
|
||||||
|
// do not seek in named pipes
|
||||||
|
if !tail.Pipe {
|
||||||
// grab the position in case we need to back up in the event of a half-line
|
// grab the position in case we need to back up in the event of a half-line
|
||||||
offset, err := tail.Tell()
|
offset, err = tail.Tell()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tail.Kill(err)
|
tail.Kill(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
line, err := tail.readLine()
|
line, err := tail.readLine()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue