fix(config): Trigger reload on correct event

Fixes #85
This commit is contained in:
Michael Carlberg
2016-11-25 11:40:32 +01:00
parent 8db3e79919
commit 4268817c51
3 changed files with 22 additions and 10 deletions

View File

@ -254,9 +254,7 @@ void controller::install_confwatch() {
return;
}
m_threads.emplace_back([this] {
this_thread::sleep_for(chrono::seconds{1});
m_threads.emplace_back([&] {
try {
if (!m_running)
return;
@ -265,13 +263,10 @@ void controller::install_confwatch() {
m_confwatch->attach(IN_MODIFY);
m_log.trace("controller: Wait for config file inotify event");
m_confwatch->get_event();
if (!m_running)
return;
m_log.info("Configuration file changed");
kill(getpid(), SIGUSR1);
if (m_confwatch->await_match() && m_running) {
m_log.info("Configuration file changed");
kill(getpid(), SIGUSR1);
}
} catch (const system_error& err) {
m_log.err(err.what());
m_log.trace("controller: Reset config watch");