1 #include "config.h"
2 
3 #include "image_manager.hpp"
4 #include "watch.hpp"
5 
6 #include <phosphor-logging/lg2.hpp>
7 #include <sdbusplus/bus.hpp>
8 
9 #include <cstdlib>
10 #include <exception>
11 
main()12 int main()
13 {
14     using namespace phosphor::software::manager;
15     auto bus = sdbusplus::bus::new_default();
16 
17     sd_event* loop = nullptr;
18     sd_event_default(&loop);
19 
20     sdbusplus::server::manager_t objManager(bus, SOFTWARE_OBJPATH);
21     bus.request_name(VERSION_BUSNAME);
22 
23     try
24     {
25         phosphor::software::manager::Manager imageManager(bus);
26         phosphor::software::manager::Watch watch(
27             loop, std::bind(std::mem_fn(&Manager::processImage), &imageManager,
28                             std::placeholders::_1));
29         bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
30         sd_event_loop(loop);
31     }
32     catch (const std::exception& e)
33     {
34         lg2::error("Error in event loop: {ERROR}", "ERROR", e);
35         return -1;
36     }
37 
38     sd_event_unref(loop);
39 
40     return 0;
41 }
42