Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LaaS
logstash-forwarder
Commits
5ba97189
Commit
5ba97189
authored
Jul 02, 2013
by
Jordan Sissel
Browse files
- truncate detection
parent
1d975fe5
Changes
1
Hide whitespace changes
Inline
Side-by-side
harvester.go
View file @
5ba97189
...
...
@@ -54,9 +54,16 @@ func (h *Harvester) Harvest(output chan *FileEvent) {
if
err
!=
nil
{
if
err
==
io
.
EOF
{
// timed out waiting for data, got eof.
// TODO(sissel): Check to see if the file was truncated
// TODO(sissel): if last_read_time was more than 24 hours ago
if
age
:=
time
.
Since
(
last_read_time
);
age
>
(
24
*
time
.
Hour
)
{
// Check to see if the file was truncated
info
,
_
:=
h
.
file
.
Stat
()
if
info
.
Size
()
<
offset
{
log
.
Printf
(
"File truncated, seeking to beginning: %s
\n
"
,
h
.
Path
)
h
.
file
.
Seek
(
0
,
os
.
SEEK_SET
)
offset
=
0
}
else
if
age
:=
time
.
Since
(
last_read_time
);
age
>
(
24
*
time
.
Hour
)
{
// if last_read_time was more than 24 hours ago, this file is probably
// dead. Stop watching it.
// TODO(sissel): Make this time configurable
// This file is idle for more than 24 hours. Give up and stop harvesting.
log
.
Printf
(
"Stopping harvest of %s; last change was %d seconds ago
\n
"
,
h
.
Path
,
age
.
Seconds
())
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment