diff --git a/conf/conf.go b/conf/conf.go index bc44712..e00b48b 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -56,16 +56,14 @@ func (p *Conf) Watch(filePath string, reload func()) error { for { select { case event := <-watcher.Events: - if event.Op&fsnotify.Chmod == fsnotify.Chmod { - if event.Name == filePath { - log.Println("config file changed, reloading...") - err := p.LoadFromPath(filePath) - if err != nil { - log.Printf("reload config error: %s", err) - } - log.Println("reload config success") - reload() + if event.Has(fsnotify.Write) { + log.Println("config dir changed, reloading...") + err := p.LoadFromPath(filePath) + if err != nil { + log.Printf("reload config error: %s", err) } + log.Println("reload config success") + reload() } case err := <-watcher.Errors: if err != nil { diff --git a/conf/conf_test.go b/conf/conf_test.go new file mode 100644 index 0000000..8f52a95 --- /dev/null +++ b/conf/conf_test.go @@ -0,0 +1 @@ +package conf