blob: bea8a13f1b1c8747be6eabb49c03fde826ba293f [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001#include "telemetry.hpp"
2
3#include <boost/asio/io_context.hpp>
4#include <boost/asio/signal_set.hpp>
5#include <phosphor-logging/log.hpp>
6#include <sdbusplus/asio/connection.hpp>
7
8#include <memory>
9#include <stdexcept>
10
11int main()
12{
13 boost::asio::io_context ioc;
14 boost::asio::signal_set signals(ioc, SIGINT, SIGTERM);
15
16 auto bus = std::make_shared<sdbusplus::asio::connection>(ioc);
17
18 constexpr const char* serviceName = "xyz.openbmc_project.Telemetry";
19 bus->request_name(serviceName);
20
21 signals.async_wait(
22 [&ioc](const boost::system::error_code ec, const int& sig) {
23 if (ec)
24 {
25 throw std::runtime_error("Signal should not be canceled");
26 }
27
28 ioc.stop();
29 });
30
31 phosphor::logging::log<phosphor::logging::level::INFO>(
32 "Telemetry starting");
33 Telemetry app(bus);
34 ioc.run();
35
36 return 0;
37}