Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "sync_manager.hpp" |
| 4 | #include "sync_watch.hpp" |
| 5 | |
| 6 | #include <systemd/sd-event.h> |
| 7 | |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 8 | #include <phosphor-logging/lg2.hpp> |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 9 | #include <sdbusplus/bus.hpp> |
| 10 | #include <sdbusplus/server/manager.hpp> |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 11 | |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 12 | #include <exception> |
| 13 | |
Adriana Kobylak | 292159f | 2020-05-05 09:25:55 -0500 | [diff] [blame] | 14 | int main() |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 15 | { |
| 16 | auto bus = sdbusplus::bus::new_default(); |
| 17 | |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 18 | sd_event* loop = nullptr; |
| 19 | sd_event_default(&loop); |
| 20 | |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 21 | sdbusplus::server::manager_t objManager(bus, SOFTWARE_OBJPATH); |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 22 | |
| 23 | try |
| 24 | { |
| 25 | phosphor::software::manager::Sync syncManager; |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 26 | |
| 27 | using namespace phosphor::software::manager; |
| 28 | phosphor::software::manager::SyncWatch watch( |
Adriana Kobylak | a907434 | 2018-05-08 11:52:44 -0500 | [diff] [blame] | 29 | *loop, std::bind(std::mem_fn(&Sync::processEntry), &syncManager, |
| 30 | std::placeholders::_1, std::placeholders::_2)); |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 31 | bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); |
| 32 | sd_event_loop(loop); |
| 33 | } |
Patrick Williams | 58e1897 | 2021-10-06 12:25:58 -0500 | [diff] [blame] | 34 | catch (const std::exception& e) |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 35 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 36 | lg2::error("Error in event loop: {ERROR}", "ERROR", e); |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 37 | sd_event_unref(loop); |
| 38 | return -1; |
| 39 | } |
| 40 | |
| 41 | sd_event_unref(loop); |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 42 | |
| 43 | return 0; |
| 44 | } |