blob: 1aeb69869f1ef4402855ca7f5a469a554acddf99 [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
Patrick Williamsc9bb6422021-08-27 06:18:35 -05006#include <phosphor-logging/lg2.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 {
Patrick Williamsc9bb6422021-08-27 06:18:35 -050034 lg2::error("Error in event loop: {ERROR}", "ERROR", e);
Deepak Kodihalli059e2332017-04-12 06:40:53 -050035 return -1;
36 }
37
38 sd_event_unref(loop);
39
Gunnar Mills01a323b2017-01-18 09:48:13 -060040 return 0;
41}