feat(scanner): add option to use fsnotify based scan watcher (#232)

* First cut at fsnotify support. Tested on Linux.

* Fixed bug in logging.

* Fixed lint issues.

* Added new scan watcher option to README.md

* Inverted conditional and dedented following code as per PR discussion.

* Changed command line switch and error return on ExecuteWatch() as per GH comments.

* Scan watcher: Removed scan at first start. Modified watcher to set a 10 second timer and then process in bulk.

Co-authored-by: Brian Doherty <brian@hplaptop.dohertyfamily.me>
This commit is contained in:
brian-doherty
2022-10-08 08:53:52 -05:00
committed by sentriz
parent bb83426816
commit ea28ff1df3
6 changed files with 143 additions and 3 deletions

View File

@@ -296,6 +296,7 @@ func (s *Server) StartHTTP(listenAddr string, tlsCert string, tlsKey string) (Fu
Addr: listenAddr,
Handler: s.router,
ReadTimeout: 5 * time.Second,
ReadHeaderTimeout: 5 * time.Second,
WriteTimeout: 80 * time.Second,
IdleTimeout: 60 * time.Second,
}
@@ -338,6 +339,16 @@ func (s *Server) StartScanTicker(dur time.Duration) (FuncExecute, FuncInterrupt)
}
}
func (s *Server) StartScanWatcher() (FuncExecute, FuncInterrupt) {
return func() error {
log.Printf("starting job 'scan watcher'\n")
return s.scanner.ExecuteWatch()
}, func(_ error) {
// stop job
s.scanner.CancelWatch()
}
}
func (s *Server) StartJukebox() (FuncExecute, FuncInterrupt) {
return func() error {
log.Printf("starting job 'jukebox'\n")