Add config watch to all tools so they are restarted if the config changes

This commit is contained in:
KemoNine 2020-09-06 03:36:35 -04:00
parent c2a21eabd9
commit 13d019cf62
3 changed files with 34 additions and 12 deletions

View File

@ -20,7 +20,18 @@ const (
func main() {
// Load the config file
pfConfig, _ := config.LoadConfig()
pfConfig, configFileProvider := config.LoadConfig()
// Watch for config changes and re-load config if needed
configFileProvider.Watch(func(event interface{}, err error) {
if err != nil {
log.Printf("Error setting up watch of config : %s", err)
return
}
// Bail on slideshow if there is a config change so it restarts with updated config
log.Fatalf("Config file changed! Exiting!")
})
log.Print("========================================")
pfConfig.Print()

View File

@ -38,18 +38,18 @@ func main() {
pfConfig.Print()
// Watch for config changes and re-load config if needed
// configFileProvider.Watch(func(event interface{}, err error) {
// if err != nil {
// log.Printf("Error setting up watch of config : %s", err)
// return
// }
configFileProvider.Watch(func(event interface{}, err error) {
if err != nil {
log.Printf("Error setting up watch of config : %s", err)
return
}
// // Give the config UI a chance to save and exit clean
// time.Sleep(time.Minute)
// Give the config UI a chance to save and exit clean
time.Sleep(time.Minute)
// // Bail on slideshow if there is a config change so it restarts with updated config
// log.Fatalf("Config file changed! Exiting!")
// })
// Bail on slideshow if there is a config change so it restarts with updated config
log.Fatalf("Config file changed! Exiting!")
})
// Process command line flags
if err := pfConfig.Load(posflag.Provider(f, ".", pfConfig), nil); err != nil {

View File

@ -18,7 +18,18 @@ const (
func main() {
// Load the config file
pfConfig, _ := config.LoadConfig()
pfConfig, configFileProvider := config.LoadConfig()
// Watch for config changes and re-load config if needed
configFileProvider.Watch(func(event interface{}, err error) {
if err != nil {
log.Printf("Error setting up watch of config : %s", err)
return
}
// Bail on slideshow if there is a config change so it restarts with updated config
log.Fatalf("Config file changed! Exiting!")
})
PATH_PICTURES := pfConfig.String(config.CONFIG_KEY_ALBUMS_ROOT)