Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 1 | #include <exception> |
| 2 | #include <phosphor-logging/log.hpp> |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 3 | #include <sdbusplus/bus.hpp> |
| 4 | #include <sdbusplus/server/manager.hpp> |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 5 | #include <systemd/sd-event.h> |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 6 | #include "config.h" |
| 7 | #include "sync_manager.hpp" |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 8 | #include "sync_watch.hpp" |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 9 | |
| 10 | int main(int argc, char* argv[]) |
| 11 | { |
| 12 | auto bus = sdbusplus::bus::new_default(); |
| 13 | |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 14 | sd_event* loop = nullptr; |
| 15 | sd_event_default(&loop); |
| 16 | |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 17 | sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH); |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 18 | |
| 19 | try |
| 20 | { |
| 21 | phosphor::software::manager::Sync syncManager; |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 22 | |
| 23 | using namespace phosphor::software::manager; |
| 24 | phosphor::software::manager::SyncWatch watch( |
Adriana Kobylak | a907434 | 2018-05-08 11:52:44 -0500 | [diff] [blame] | 25 | *loop, std::bind(std::mem_fn(&Sync::processEntry), &syncManager, |
| 26 | std::placeholders::_1, std::placeholders::_2)); |
Adriana Kobylak | b072d1b | 2018-04-24 11:37:21 -0500 | [diff] [blame] | 27 | bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); |
| 28 | sd_event_loop(loop); |
| 29 | } |
| 30 | catch (std::exception& e) |
| 31 | { |
| 32 | using namespace phosphor::logging; |
| 33 | log<level::ERR>(e.what()); |
| 34 | sd_event_unref(loop); |
| 35 | return -1; |
| 36 | } |
| 37 | |
| 38 | sd_event_unref(loop); |
Adriana Kobylak | 7e8d76b | 2018-04-20 10:03:01 -0500 | [diff] [blame] | 39 | |
| 40 | return 0; |
| 41 | } |