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 | |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 17 | sdbusplus::server::manager::manager objManager(bus, |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 18 | SOFTWARE_OBJPATH); |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 19 | bus.request_name(VERSION_BUSNAME); |
| 20 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 21 | try |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 22 | { |
Gunnar Mills | 3027bba | 2017-04-27 15:49:03 -0500 | [diff] [blame] | 23 | phosphor::software::manager::Manager imageManager(bus); |
Gunnar Mills | 9b200b0 | 2017-09-18 11:16:37 -0500 | [diff] [blame] | 24 | phosphor::software::manager::Watch watch( |
| 25 | loop, |
| 26 | std::bind(std::mem_fn(&Manager::processImage), |
| 27 | &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 | } |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 32 | catch (std::exception& e) |
| 33 | { |
| 34 | using namespace phosphor::logging; |
| 35 | log<level::ERR>(e.what()); |
| 36 | return -1; |
| 37 | } |
| 38 | |
| 39 | sd_event_unref(loop); |
| 40 | |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 41 | return 0; |
| 42 | } |