blob: 3aeefbe94ccaf62b63fa86ba0b78a879a5b2769f [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{
11 auto bus = sdbusplus::bus::new_default();
12
Deepak Kodihalli059e2332017-04-12 06:40:53 -050013 sd_event* loop = nullptr;
14 sd_event_default(&loop);
15
Gunnar Mills01a323b2017-01-18 09:48:13 -060016 sdbusplus::server::manager::manager objManager(bus,
17 SOFTWARE_OBJPATH);
Gunnar Mills01a323b2017-01-18 09:48:13 -060018 bus.request_name(VERSION_BUSNAME);
19
Deepak Kodihalli059e2332017-04-12 06:40:53 -050020 try
Gunnar Mills01a323b2017-01-18 09:48:13 -060021 {
Gunnar Mills3027bba2017-04-27 15:49:03 -050022 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 Kodihalli059e2332017-04-12 06:40:53 -050028 bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
29 sd_event_loop(loop);
Gunnar Mills01a323b2017-01-18 09:48:13 -060030 }
Deepak Kodihalli059e2332017-04-12 06:40:53 -050031 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 Mills01a323b2017-01-18 09:48:13 -060040 return 0;
41}