monitor:SIGHUP: Handle reloading JSON config thru SIGHUP
Enable capturing the HUP signal to reload the JSON configuration. This
will reload the appropriate JSON configuration file found and update the
trust groups and fan definitions configured.
Tested:
JSON configuration is reloaded and updated after SIGHUP
Single instance of trust groups exist that match the JSON config
Single instance of fan definitions exist that match the JSON config
Change-Id: If55ca583a67fd76f0733009707bd5c4b5eda3e63
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/main.cpp b/monitor/main.cpp
index 7517d6d..f0458f9 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -13,6 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include "config.h"
+
#include "argument.hpp"
#include "fan.hpp"
#include "system.hpp"
@@ -21,6 +23,8 @@
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
+#include <sdeventplus/source/signal.hpp>
+#include <stdplus/signal.hpp>
using namespace phosphor::fan::monitor;
using namespace phosphor::logging;
@@ -58,6 +62,15 @@
System system(mode, bus, event);
+#ifdef MONITOR_USE_JSON
+ // Enable SIGHUP handling to reload JSON config
+ stdplus::signal::block(SIGHUP);
+ sdeventplus::source::Signal signal(event, SIGHUP,
+ std::bind(&System::sighupHandler,
+ &system, std::placeholders::_1,
+ std::placeholders::_2));
+#endif
+
if (mode == Mode::init)
{
// Fans were initialized to be functional, exit