Skip to content

Commit

Permalink
check for new lines when detecting renamed logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
fstab committed May 31, 2019
1 parent b4c308b commit cde2d12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/fstab/grok_exporter
require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/bitly/go-simplejson v0.5.0
github.com/prometheus/client_golang v0.9.2
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275
Expand Down
9 changes: 7 additions & 2 deletions tailer/fswatcher/fswatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ func (t *fileTailer) syncFilesInDir(dir *Dir, readall bool, log logrus.FieldLogg
renamedFile.Close()
return Err
}
alreadyWatched.file = renamedFile
watchedFilesAfter[filePath] = alreadyWatched // re-use lineReader
alreadyWatched.file = renamedFile // re-use lineReader
Err = t.readNewLines(alreadyWatched, fileLogger)
if Err != nil {
alreadyWatched.file.Close()
return Err
}
watchedFilesAfter[filePath] = alreadyWatched
} else {
fileLogger.Debug("skipping, because file is already watched")
watchedFilesAfter[filePath] = alreadyWatched
Expand Down

0 comments on commit cde2d12

Please sign in to comment.