disable config file watch

This commit is contained in:
Paolo Asperti 2021-12-09 18:14:28 +01:00
parent 6f70a6aab3
commit 32006e6598
Signed by: paspo
GPG Key ID: 06D46905D19D5182

View File

@ -3,9 +3,7 @@ package main
import (
"fmt"
"git.openpdu.org/OpenPDU/openpdu/events"
"git.openpdu.org/OpenPDU/openpdu/syslog"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
@ -18,10 +16,12 @@ func init() {
if err != nil { // Handle errors reading the config file
syslog.Err(fmt.Sprintf("Can't read config file: %s \n", err.Error()))
}
viper.OnConfigChange(func(e fsnotify.Event) {
//The Viper configuration has changed to perform the responding operation
fmt.Println("Config file changed:", e.Name)
events.FireEvent("config_changed")
})
viper.WatchConfig()
// temporary disabled because it screwsup the config on save
// viper.OnConfigChange(func(e fsnotify.Event) {
// //The Viper configuration has changed to perform the responding operation
// fmt.Println("Config file changed:", e.Name)
// events.FireEvent("config_changed")
// })
// viper.WatchConfig()
}