watch: Unsubscribe from fsnotify synchronously.

Calling watcher.Remove() from the run() goroutine is now problematic,
because with the change made in fsnotify/fsnotify#73 Remove() can now
take an arbitrary amount of time, which means we can deadlock if run()
is waiting for fsnotify to acknowledge the removal and fsnotify is
trying to send an unrelated Event.

So instead we now do part of the cleanup, including calling Remove(),
synchronously, in the goroutine trying to unsubscribe.

This fixes #75.  Thanks to Aaron Beitch for the fix.

Change-Id: I346c9eecc34b2378312b07b3c3efc41616b95380
1 file changed
tree: e20fc6db0c044f17a63703d00cde70334d3e3a39
  1. cmd/
  2. ratelimiter/
  3. util/
  4. watch/
  5. winfile/
  6. .gitignore
  7. .travis.yml
  8. CHANGES.md
  9. deps.json
  10. Dockerfile
  11. LICENSE.txt
  12. Makefile
  13. README.md
  14. tail.go
  15. tail_posix.go
  16. tail_test.go
  17. tail_windows.go
README.md

Build Status

Go package for tail-ing files

A Go package striving to emulate the features of the BSD tail program.

t, err := tail.TailFile("/var/log/nginx.log", tail.Config{Follow: true})
for line := range t.Lines {
    fmt.Println(line.Text)
}

See API documentation.

Log rotation

Tail comes with full support for truncation/move detection as it is designed to work with log rotation tools.

Installing

go get github.com/hpcloud/tail/...

Windows support

This package needs assistance for full Windows support.