Notice configuration changes and restart the watchers.

This commit is contained in:
2021-10-10 13:43:36 +10:30
parent 90f8c3588b
commit fd6f6884ee
4 changed files with 146 additions and 25 deletions

View File

@@ -38,7 +38,8 @@ type ConfigV2 struct {
}
type ConfigService struct {
Config ConfigV2
Config *ConfigV2
Changed chan bool
ConfigFilename string
}
@@ -57,7 +58,7 @@ func (c *ConfigService) LoadOrInit() error {
if os.IsNotExist(err) {
daulog.SendLog("NOTE: No config file, writing out sample configuration", daulog.LogTypeInfo)
daulog.SendLog("You need to set the configuration via the web interface", daulog.LogTypeInfo)
c.Config = *DefaultConfig()
c.Config = DefaultConfig()
return c.Save()
} else {
return c.Load()
@@ -158,6 +159,7 @@ func (c *ConfigService) Save() error {
if err != nil {
return fmt.Errorf("cannot save config %s: %s", c.ConfigFilename, err.Error())
}
return nil
}