blob: 59a2d30a0623b5c42fef25a0db977d06f5697d59 [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) {
Patrick Williams3a1c2972023-05-10 07:51:04 -050023 if (ec)
24 {
25 throw std::runtime_error("Signal should not be canceled");
26 }
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020027
Patrick Williams3a1c2972023-05-10 07:51:04 -050028 ioc.stop();
29 });
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020030
31 phosphor::logging::log<phosphor::logging::level::INFO>(
32 "Telemetry starting");
33 Telemetry app(bus);
34 ioc.run();
35
36 return 0;
37}