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 | |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 6 | #include <cstdlib> |
| 7 | #include <exception> |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 8 | #include <phosphor-logging/log.hpp> |
Gunnar Mills | b0ce996 | 2018-09-07 13:39:10 -0500 | [diff] [blame] | 9 | #include <sdbusplus/bus.hpp> |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 10 | |
| 11 | int main(int argc, char* argv[]) |
| 12 | { |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 13 | using namespace phosphor::software::manager; |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 14 | auto bus = sdbusplus::bus::new_default(); |
| 15 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 16 | sd_event* loop = nullptr; |
| 17 | sd_event_default(&loop); |
| 18 | |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 19 | sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH); |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 20 | bus.request_name(VERSION_BUSNAME); |
| 21 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 22 | try |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 23 | { |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 24 | phosphor::software::manager::Manager imageManager(bus); |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 25 | phosphor::software::manager::Watch watch( |
Adriana Kobylak | 2285fe0 | 2018-02-27 15:36:59 -0600 | [diff] [blame] | 26 | loop, std::bind(std::mem_fn(&Manager::processImage), &imageManager, |
| 27 | std::placeholders::_1)); |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 28 | bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL); |
| 29 | sd_event_loop(loop); |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 30 | } |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 31 | catch (std::exception& e) |
| 32 | { |
| 33 | using namespace phosphor::logging; |
| 34 | log<level::ERR>(e.what()); |
| 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 | } |