Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions bridge/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config {

cfgtype := detectConfigType(cfgfile)
mycfg := newConfigFromString(logger, input, cfgtype)
// TODO: log file should probably also be reloaded
if mycfg.cv.General.LogFile != "" {
logfile, err := os.OpenFile(mycfg.cv.General.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0600)
if err == nil {
Expand All @@ -322,6 +323,20 @@ func NewConfig(rootLogger *logrus.Logger, cfgfile string) Config {
viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {
logger.Println("Config file changed:", e.Name)
// Reload BridgeValues as exposed in the Router
// TODO: are we breaking some stuff that should *not* be reloaded here? Should
// we only reload General section?
//
// This is where syntax errors are caught
err = viper.ReadInConfig()
if err != nil {
logger.Errorf("%v", err)
}

err = viper.Unmarshal(&mycfg.cv)
if err != nil {
logger.Fatalf("This should not happen when reloading config: %v", err)
}
})
return mycfg
}
Expand Down
Loading