blob: 758abcf7a3a52d8bd0df06d9ca8f96baf5cb07bd [file] [log] [blame]
Gunnar Millsb0ce9962018-09-07 13:39:10 -05001#include "config.h"
2
3#include "sync_manager.hpp"
4#include "sync_watch.hpp"
5
6#include <systemd/sd-event.h>
7
Patrick Williamsc9bb6422021-08-27 06:18:35 -05008#include <phosphor-logging/lg2.hpp>
Adriana Kobylak7e8d76b2018-04-20 10:03:01 -05009#include <sdbusplus/bus.hpp>
10#include <sdbusplus/server/manager.hpp>
Adriana Kobylak7e8d76b2018-04-20 10:03:01 -050011
Adriana Kobylak58aa7502020-06-08 11:12:11 -050012#include <exception>
13
Adriana Kobylak292159f2020-05-05 09:25:55 -050014int main()
Adriana Kobylak7e8d76b2018-04-20 10:03:01 -050015{
16 auto bus = sdbusplus::bus::new_default();
17
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050018 sd_event* loop = nullptr;
19 sd_event_default(&loop);
20
Patrick Williamsbf2bb2b2022-07-22 19:26:52 -050021 sdbusplus::server::manager_t objManager(bus, SOFTWARE_OBJPATH);
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050022
23 try
24 {
25 phosphor::software::manager::Sync syncManager;
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050026
27 using namespace phosphor::software::manager;
28 phosphor::software::manager::SyncWatch watch(
Adriana Kobylaka9074342018-05-08 11:52:44 -050029 *loop, std::bind(std::mem_fn(&Sync::processEntry), &syncManager,
30 std::placeholders::_1, std::placeholders::_2));
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050031 bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
32 sd_event_loop(loop);
33 }
Patrick Williams58e18972021-10-06 12:25:58 -050034 catch (const std::exception& e)
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050035 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050036 lg2::error("Error in event loop: {ERROR}", "ERROR", e);
Adriana Kobylakb072d1b2018-04-24 11:37:21 -050037 sd_event_unref(loop);
38 return -1;
39 }
40
41 sd_event_unref(loop);
Adriana Kobylak7e8d76b2018-04-20 10:03:01 -050042
43 return 0;
44}