Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
| 3 | #include "image_manager.hpp" |
| 4 | #include "watch.hpp" |
| 5 | |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 6 | #include <phosphor-logging/lg2.hpp> |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 7 | #include <sdbusplus/bus.hpp> |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 8 | |
Adriana Kobylak | 58aa750 | 2020-06-08 11:12:11 -0500 | [diff] [blame] | 9 | #include <cstdlib> |
| 10 | #include <exception> |
| 11 | |
Adriana Kobylak | 292159f | 2020-05-05 09:25:55 -0500 | [diff] [blame] | 12 | int main() |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 13 | { |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 14 | using namespace phosphor::software::manager; |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 15 | auto bus = sdbusplus::bus::new_default(); |
| 16 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 17 | sd_event* loop = nullptr; |
| 18 | sd_event_default(&loop); |
| 19 | |
Patrick Williams | bf2bb2b | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 20 | sdbusplus::server::manager_t objManager(bus, SOFTWARE_OBJPATH); |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 21 | bus.request_name(VERSION_BUSNAME); |
| 22 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 23 | try |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 24 | { |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 25 | phosphor::software::manager::Manager imageManager(bus); |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 26 | phosphor::software::manager::Watch watch( |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 27 | loop, std::bind(std::mem_fn(&Manager::processImage), &imageManager, |
| 28 | std::placeholders::_1)); |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 29 | bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); |
| 30 | sd_event_loop(loop); |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 31 | } |
Patrick Williams | 58e1897 | 2021-10-06 12:25:58 -0500 | [diff] [blame] | 32 | catch (const std::exception& e) |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 33 | { |
Patrick Williams | c9bb642 | 2021-08-27 06:18:35 -0500 | [diff] [blame] | 34 | lg2::error("Error in event loop: {ERROR}", "ERROR", e); |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 35 | return -1; |
| 36 | } |
| 37 | |
| 38 | sd_event_unref(loop); |
| 39 | |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 40 | return 0; |
| 41 | } |