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