mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-12 18:48:12 -05:00
update watcher
This commit is contained in:
parent
e20c9b9290
commit
7d1b916bac
@ -56,9 +56,8 @@ func (p *Conf) Watch(filePath string, reload func()) error {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case event := <-watcher.Events:
|
case event := <-watcher.Events:
|
||||||
if event.Op&fsnotify.Chmod == fsnotify.Chmod {
|
if event.Has(fsnotify.Write) {
|
||||||
if event.Name == filePath {
|
log.Println("config dir changed, reloading...")
|
||||||
log.Println("config file changed, reloading...")
|
|
||||||
err := p.LoadFromPath(filePath)
|
err := p.LoadFromPath(filePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("reload config error: %s", err)
|
log.Printf("reload config error: %s", err)
|
||||||
@ -66,7 +65,6 @@ func (p *Conf) Watch(filePath string, reload func()) error {
|
|||||||
log.Println("reload config success")
|
log.Println("reload config success")
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case err := <-watcher.Errors:
|
case err := <-watcher.Errors:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("watcher error: %s", err)
|
log.Panicf("watcher error: %s", err)
|
||||||
|
1
conf/conf_test.go
Normal file
1
conf/conf_test.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package conf
|
Loading…
Reference in New Issue
Block a user