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 | { |
| 11 | auto bus = sdbusplus::bus::new_default(); |
| 12 | |
Deepak Kodihalli | 059e233 | 2017-04-12 06:40:53 -0500 | [diff] [blame] | 13 | sd_event* loop = nullptr; |
| 14 | sd_event_default(&loop); |
| 15 | |
Gunnar Mills | 01a323b | 2017-01-18 09:48:13 -0600 | [diff] [blame] | 16 | sdbusplus::server::manager::manager objManager(bus, |
| 17 | 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); |
| 23 | phosphor::software::manager::Watch watch(loop, |
| 24 | std::bind( |
| 25 | std::mem_fn( |
| 26 | &phosphor::software::manager::Manager::processImage), |
| 27 | &imageManager, 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 | } |