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/system.hpp b/monitor/system.hpp
index c72f0d5..9757082 100644
--- a/monitor/system.hpp
+++ b/monitor/system.hpp
@@ -23,6 +23,7 @@
#include <nlohmann/json.hpp>
#include <sdbusplus/bus.hpp>
#include <sdeventplus/event.hpp>
+#include <sdeventplus/source/signal.hpp>
#include <memory>
#include <optional>
@@ -54,6 +55,13 @@
System(Mode mode, sdbusplus::bus::bus& bus,
const sdeventplus::Event& event);
+ /**
+ * @brief Callback function to handle receiving a HUP signal to reload the
+ * JSON configuration.
+ */
+ void sighupHandler(sdeventplus::source::Signal&,
+ const struct signalfd_siginfo*);
+
private:
/* The mode of fan monitor */
Mode _mode;
@@ -80,6 +88,13 @@
const std::vector<CreateGroupFunction> getTrustGroups(const json& jsonObj);
/**
+ * @brief Set the trust manager's list of trust group functions
+ *
+ * @param[in] groupFuncs - list of trust group functions
+ */
+ void setTrustMgr(const std::vector<CreateGroupFunction>& groupFuncs);
+
+ /**
* @brief Retrieve the configured fan definitions
*
* @param[in] jsonObj - JSON object to parse from
@@ -87,6 +102,13 @@
* @return List of fan definition data on the fans configured
*/
const std::vector<FanDefinition> getFanDefinitions(const json& jsonObj);
+
+ /**
+ * @brief Set the list of fans to be monitored
+ *
+ * @param[in] fanDefs - list of fan definitions to create fans monitored
+ */
+ void setFans(const std::vector<FanDefinition>& fanDefs);
};
} // namespace phosphor::fan::monitor