Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Commit 7d1b916

Browse files
committed
update watcher
1 parent e20c9b9 commit 7d1b916

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

conf/conf.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,14 @@ func (p *Conf) Watch(filePath string, reload func()) error {
5656
for {
5757
select {
5858
case event := <-watcher.Events:
59-
if event.Op&fsnotify.Chmod == fsnotify.Chmod {
60-
if event.Name == filePath {
61-
log.Println("config file changed, reloading...")
62-
err := p.LoadFromPath(filePath)
63-
if err != nil {
64-
log.Printf("reload config error: %s", err)
65-
}
66-
log.Println("reload config success")
67-
reload()
59+
if event.Has(fsnotify.Write) {
60+
log.Println("config dir changed, reloading...")
61+
err := p.LoadFromPath(filePath)
62+
if err != nil {
63+
log.Printf("reload config error: %s", err)
6864
}
65+
log.Println("reload config success")
66+
reload()
6967
}
7068
case err := <-watcher.Errors:
7169
if err != nil {

conf/conf_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package conf

0 commit comments

Comments
 (0)