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