blob: 7b4e18ee088f36e10f32fc0016fa45963c11288b [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
Deepak Kodihalli059e2332017-04-12 06:40:53 -05006#include <phosphor-logging/log.hpp>
Gunnar Millsb0ce9962018-09-07 13:39:10 -05007#include <sdbusplus/bus.hpp>
Gunnar Mills01a323b2017-01-18 09:48:13 -06008
Adriana Kobylak58aa7502020-06-08 11:12:11 -05009#include <cstdlib>
10#include <exception>
11
Adriana Kobylak292159f2020-05-05 09:25:55 -050012int main()
Gunnar Mills01a323b2017-01-18 09:48:13 -060013{
Gunnar Mills9b200b02017-09-18 11:16:37 -050014 using namespace phosphor::software::manager;
Gunnar Mills01a323b2017-01-18 09:48:13 -060015 auto bus = sdbusplus::bus::new_default();
16
Deepak Kodihalli059e2332017-04-12 06:40:53 -050017 sd_event* loop = nullptr;
18 sd_event_default(&loop);
19
Adriana Kobylak2285fe02018-02-27 15:36:59 -060020 sdbusplus::server::manager::manager objManager(bus, SOFTWARE_OBJPATH);
Gunnar Mills01a323b2017-01-18 09:48:13 -060021 bus.request_name(VERSION_BUSNAME);
22
Deepak Kodihalli059e2332017-04-12 06:40:53 -050023 try
Gunnar Mills01a323b2017-01-18 09:48:13 -060024 {
Gunnar Mills3027bba2017-04-27 15:49:03 -050025 phosphor::software::manager::Manager imageManager(bus);
Gunnar Mills9b200b02017-09-18 11:16:37 -050026 phosphor::software::manager::Watch watch(
Adriana Kobylak2285fe02018-02-27 15:36:59 -060027 loop, std::bind(std::mem_fn(&Manager::processImage), &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}