summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--monitor/main.cpp44
1 files changed, 43 insertions, 1 deletions
diff --git a/monitor/main.cpp b/monitor/main.cpp
index e468bac..6d51fbb 100644
--- a/monitor/main.cpp
+++ b/monitor/main.cpp
@@ -13,9 +13,51 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
+#include "fan.hpp"
+#include "fan_defs.hpp"
+using namespace phosphor::fan::monitor;
+using namespace phosphor::logging;
+
+
+void EventDeleter(sd_event* event)
+{
+ sd_event_unref(event);
+}
int main()
{
- return 0;
+ auto bus = sdbusplus::bus::new_default();
+ sd_event* events = nullptr;
+ std::vector<std::unique_ptr<Fan>> fans;
+
+ auto r = sd_event_default(&events);
+ if (r < 0)
+ {
+ log<level::ERR>("Failed call to sd_event_default()",
+ entry("ERROR=%s", strerror(-r)));
+ return -1;
+ }
+
+ std::shared_ptr<sd_event> eventPtr{events, EventDeleter};
+
+ //Attach the event object to the bus object so we can
+ //handle both sd_events (for the timers) and dbus signals.
+ bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL);
+
+ for (const auto& fanDef : fanDefinitions)
+ {
+ fans.emplace_back(std::make_unique<Fan>(bus, eventPtr, fanDef));
+ }
+
+ r = sd_event_loop(eventPtr.get());
+ if (r < 0)
+ {
+ log<level::ERR>("Failed call to sd_event_loop",
+ entry("ERROR=%s", strerror(-r)));
+ }
+
+ return -1;
}
OpenPOWER on IntegriCloud