mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
update watcher
This commit is contained in:
16
conf/conf.go
16
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 {
|
||||
|
||||
1
conf/conf_test.go
Normal file
1
conf/conf_test.go
Normal file
@@ -0,0 +1 @@
|
||||
package conf
|
||||
Reference in New Issue
Block a user