blob: 71cf37dbbf99f85a4c932d82bde310b4aa9b8f42 [file] [log] [blame]
Gunnar Mills01a323b2017-01-18 09:48:13 -06001#include <cstdlib>
2#include <exception>
3#include <sdbusplus/bus.hpp>
Deepak Kodihalli059e2332017-04-12 06:40:53 -05004#include <phosphor-logging/log.hpp>
Gunnar Mills01a323b2017-01-18 09:48:13 -06005#include "config.h"
Deepak Kodihalli059e2332017-04-12 06:40:53 -05006#include "watch.hpp"
Gunnar Mills3027bba2017-04-27 15:49:03 -05007#include "image_manager.hpp"
Gunnar Mills01a323b2017-01-18 09:48:13 -06008
9int main(int argc, char* argv[])
10{
Gunnar Mills9b200b02017-09-18 11:16:37 -050011 using namespace phosphor::software::manager;
Gunnar Mills01a323b2017-01-18 09:48:13 -060012 auto bus = sdbusplus::bus::new_default();
13
Deepak Kodihalli059e2332017-04-12 06:40:53 -050014 sd_event* loop = nullptr;
15 sd_event_default(&loop);
16
Gunnar Mills01a323b2017-01-18 09:48:13 -060017 sdbusplus::server::manager::manager objManager(bus,
Gunnar Mills9b200b02017-09-18 11:16:37 -050018 SOFTWARE_OBJPATH);
Gunnar Mills01a323b2017-01-18 09:48:13 -060019 bus.request_name(VERSION_BUSNAME);
20
Deepak Kodihalli059e2332017-04-12 06:40:53 -050021 try
Gunnar Mills01a323b2017-01-18 09:48:13 -060022 {
Gunnar Mills3027bba2017-04-27 15:49:03 -050023 phosphor::software::manager::Manager imageManager(bus);
Gunnar Mills9b200b02017-09-18 11:16:37 -050024 phosphor::software::manager::Watch watch(
25 loop,
26 std::bind(std::mem_fn(&Manager::processImage),
27 &imageManager,
28 std::placeholders::_1));
Deepak Kodihalli059e2332017-04-12 06:40:53 -050029 bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
30 sd_event_loop(loop);
Gunnar Mills01a323b2017-01-18 09:48:13 -060031 }
Deepak Kodihalli059e2332017-04-12 06:40:53 -050032 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 Mills01a323b2017-01-18 09:48:13 -060041 return 0;
42}