blob: 867a96024270a06e5b3c3856930da66434387111 [file] [log] [blame]
Gunnar Millsb0ce9962018-09-07 13:39:10 -05001#include "config.h"
2
3#include "image_manager.hpp"
4#include "watch.hpp"
5
Gunnar Mills01a323b2017-01-18 09:48:13 -06006#include <cstdlib>
7#include <exception>
Deepak Kodihalli059e2332017-04-12 06:40:53 -05008#include <phosphor-logging/log.hpp>
Gunnar Millsb0ce9962018-09-07 13:39:10 -05009#include <sdbusplus/bus.hpp>
Gunnar Mills01a323b2017-01-18 09:48:13 -060010
Adriana Kobylak292159f2020-05-05 09:25:55 -050011int main()
Gunnar Mills01a323b2017-01-18 09:48:13 -060012{
Gunnar Mills9b200b02017-09-18 11:16:37 -050013 using namespace phosphor::software::manager;
Gunnar Mills01a323b2017-01-18 09:48:13 -060014 auto bus = sdbusplus::bus::new_default();
15
Deepak Kodihalli059e2332017-04-12 06:40:53 -050016 sd_event* loop = nullptr;
17 sd_event_default(&loop);
18
Adriana Kobylak2285fe02018-02-27 15:36:59 -060019 sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
Gunnar Mills01a323b2017-01-18 09:48:13 -060020 bus.request_name(VERSION_BUSNAME);
21
Deepak Kodihalli059e2332017-04-12 06:40:53 -050022 try
Gunnar Mills01a323b2017-01-18 09:48:13 -060023 {
Gunnar Mills3027bba2017-04-27 15:49:03 -050024 phosphor::software::manager::Manager imageManager(bus);
Gunnar Mills9b200b02017-09-18 11:16:37 -050025 phosphor::software::manager::Watch watch(
Adriana Kobylak2285fe02018-02-27 15:36:59 -060026 loop, std::bind(std::mem_fn(&Manager::processImage), &imageManager,
27 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}