Gunnar Mills | f6ed589 | 2018-09-07 17:08:02 -0500 | [diff] [blame^] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "item_updater.hpp" |
| 4 | #include "watch.hpp" |
| 5 | |
| 6 | #include <phosphor-logging/log.hpp> |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
| 8 | #include <sdbusplus/server/manager.hpp> |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 9 | #include <system_error> |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 10 | |
| 11 | int main(int argc, char* argv[]) |
| 12 | { |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 13 | using namespace openpower::software::updater; |
| 14 | using namespace phosphor::logging; |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 15 | auto bus = sdbusplus::bus::new_default(); |
| 16 | |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 17 | sd_event* loop = nullptr; |
| 18 | auto rc = sd_event_default(&loop); |
| 19 | if (rc < 0) |
| 20 | { |
| 21 | log<level::ERR>("Error occurred during the sd_event_default", |
| 22 | entry("RC=%d", rc)); |
| 23 | return -1; |
| 24 | } |
| 25 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 26 | // Add sdbusplus ObjectManager. |
| 27 | sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH); |
| 28 | |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 29 | ItemUpdater updater(bus, SOFTWARE_OBJPATH); |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 30 | |
| 31 | bus.request_name(BUSNAME_UPDATER); |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 32 | try |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 33 | { |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 34 | openpower::software::updater::Watch watch( |
Adriana Kobylak | 70dcb63 | 2018-02-27 15:46:52 -0600 | [diff] [blame] | 35 | loop, |
| 36 | std::bind(std::mem_fn(&ItemUpdater::updateFunctionalAssociation), |
| 37 | &updater, std::placeholders::_1)); |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 38 | bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); |
| 39 | auto rc = sd_event_loop(loop); |
| 40 | if (rc < 0) |
| 41 | { |
| 42 | log<level::ERR>("Error occurred during the sd_event_loop", |
| 43 | entry("RC=%d", rc)); |
| 44 | return -1; |
| 45 | } |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 46 | } |
Gunnar Mills | 6bd6d7b | 2017-09-18 09:22:36 -0500 | [diff] [blame] | 47 | catch (const std::system_error& e) |
| 48 | { |
| 49 | log<level::ERR>(e.what()); |
| 50 | return -1; |
| 51 | } |
| 52 | |
| 53 | sd_event_unref(loop); |
| 54 | |
Adriana Kobylak | 2d8fa22 | 2017-03-15 12:34:32 -0500 | [diff] [blame] | 55 | return 0; |
| 56 | } |