colse file just one time
This commit is contained in:
parent
6aef373ea6
commit
2bc904e34f
9
tail.go
9
tail.go
|
@ -153,15 +153,18 @@ func (tail *Tail) Stop() error {
|
||||||
|
|
||||||
func (tail *Tail) close() {
|
func (tail *Tail) close() {
|
||||||
close(tail.Lines)
|
close(tail.Lines)
|
||||||
|
tail.colseFile()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tail *Tail) colseFile() {
|
||||||
if tail.file != nil {
|
if tail.file != nil {
|
||||||
tail.file.Close()
|
tail.file.Close()
|
||||||
|
tail.file = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tail *Tail) reopen() error {
|
func (tail *Tail) reopen() error {
|
||||||
if tail.file != nil {
|
tail.colseFile()
|
||||||
tail.file.Close()
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
var err error
|
var err error
|
||||||
tail.file, err = OpenFile(tail.Filename)
|
tail.file, err = OpenFile(tail.Filename)
|
||||||
|
|
Loading…
Reference in New Issue