diff --git a/include/components/config.hpp b/include/components/config.hpp index b3a894e6..d0be66d4 100644 --- a/include/components/config.hpp +++ b/include/components/config.hpp @@ -44,6 +44,8 @@ class config { void set_included(file_list included); + file_list get_included_files() const; + void warn_deprecated(const string& section, const string& key, string replacement) const; /** @@ -225,10 +227,9 @@ class config { return value; } catch (const key_error& err) { return get(section, newkey, fallback); - } - catch (const std::exception& err) { - m_log.err("Invalid value for \"%s.%s\", using fallback key \"%s.%s\" (reason: %s)", - section, old, section, newkey, err.what()); + } catch (const std::exception& err) { + m_log.err("Invalid value for \"%s.%s\", using fallback key \"%s.%s\" (reason: %s)", section, old, section, newkey, + err.what()); return get(section, newkey, fallback); } } diff --git a/include/components/controller.hpp b/include/components/controller.hpp index 0eec49c0..cb0a72e7 100644 --- a/include/components/controller.hpp +++ b/include/components/controller.hpp @@ -55,6 +55,7 @@ class controller : public signal_receiver(); + fs_event_handler.start( + filename, 0, [this](const auto& e) { confwatch_handler(e.path); }, + [this, &fs_event_handler](const auto& e) { + m_log.err("libuv error while watching included file for changes: %s", uv_strerror(e.status)); + fs_event_handler.close(); + }); +} + void controller::confwatch_handler(const char* filename) { m_log.notice("Watched config file changed %s", filename); stop(true); @@ -251,13 +261,11 @@ void controller::read_events(bool confwatch) { } if (confwatch) { - auto& fs_event_handle = m_loop.handle(); - fs_event_handle.start( - m_conf.filepath(), 0, [this](const auto& e) { confwatch_handler(e.path); }, - [this, &fs_event_handle](const auto& e) { - m_log.err("libuv error while watching config file for changes: %s", uv_strerror(e.status)); - fs_event_handle.close(); - }); + create_config_watcher(m_conf.filepath()); + // also watch the include-files for changes + for (auto& module_path : m_conf.get_included_files()) { + create_config_watcher(module_path); + } } if (!m_snapshot_dst.empty()) {