defaults to inotify to detect changes in file datasource to avoid too many call to stat() (#2181)
This commit is contained in:
parent
e1f4a71357
commit
2701454f23
|
@ -39,6 +39,7 @@ type FileConfiguration struct {
|
||||||
Filename string
|
Filename string
|
||||||
ForceInotify bool `yaml:"force_inotify"`
|
ForceInotify bool `yaml:"force_inotify"`
|
||||||
MaxBufferSize int `yaml:"max_buffer_size"`
|
MaxBufferSize int `yaml:"max_buffer_size"`
|
||||||
|
PollWithoutInotify bool `yaml:"poll_without_inotify"`
|
||||||
configuration.DataSourceCommonCfg `yaml:",inline"`
|
configuration.DataSourceCommonCfg `yaml:",inline"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +329,7 @@ func (f *FileSource) StreamingAcquisition(out chan types.Event, t *tomb.Tomb) er
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
tail, err := tail.TailFile(file, tail.Config{ReOpen: true, Follow: true, Poll: true, Location: &tail.SeekInfo{Offset: 0, Whence: io.SeekEnd}, Logger: log.NewEntry(log.StandardLogger())})
|
tail, err := tail.TailFile(file, tail.Config{ReOpen: true, Follow: true, Poll: f.config.PollWithoutInotify, Location: &tail.SeekInfo{Offset: 0, Whence: io.SeekEnd}, Logger: log.NewEntry(log.StandardLogger())})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.logger.Errorf("Could not start tailing file %s : %s", file, err)
|
f.logger.Errorf("Could not start tailing file %s : %s", file, err)
|
||||||
continue
|
continue
|
||||||
|
@ -411,7 +412,7 @@ func (f *FileSource) monitorNewFiles(out chan types.Event, t *tomb.Tomb) error {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
//Slightly different parameters for Location, as we want to read the first lines of the newly created file
|
//Slightly different parameters for Location, as we want to read the first lines of the newly created file
|
||||||
tail, err := tail.TailFile(event.Name, tail.Config{ReOpen: true, Follow: true, Poll: true, Location: &tail.SeekInfo{Offset: 0, Whence: io.SeekStart}})
|
tail, err := tail.TailFile(event.Name, tail.Config{ReOpen: true, Follow: true, Poll: f.config.PollWithoutInotify, Location: &tail.SeekInfo{Offset: 0, Whence: io.SeekStart}})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("Could not start tailing file %s : %s", event.Name, err)
|
logger.Errorf("Could not start tailing file %s : %s", event.Name, err)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue