blob: 419b467b5cd95250530ec532668b6a7c05609299 [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
Adriana Kobylak2285fe02018-02-27 15:36:59 -060017 sdbusplus::server::manager::manager objManager(bus, 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);
Gunnar Mills9b200b02017-09-18 11:16:37 -050023 phosphor::software::manager::Watch watch(
Adriana Kobylak2285fe02018-02-27 15:36:59 -060024 loop, std::bind(std::mem_fn(&Manager::processImage), &imageManager,
25 std::placeholders::_1));
Deepak Kodihalli059e2332017-04-12 06:40:53 -050026 bus.attach_event(loop, SD_EVENT_PRIORITY_NORMAL);
27 sd_event_loop(loop);
Gunnar Mills01a323b2017-01-18 09:48:13 -060028 }
Deepak Kodihalli059e2332017-04-12 06:40:53 -050029 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 Mills01a323b2017-01-18 09:48:13 -060038 return 0;
39}