Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 1 | #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 | |
| 11 | int 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 Williams | 3a1c297 | 2023-05-10 07:51:04 -0500 | [diff] [blame] | 23 | if (ec) |
| 24 | { |
| 25 | throw std::runtime_error("Signal should not be canceled"); |
| 26 | } |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 27 | |
Patrick Williams | 3a1c297 | 2023-05-10 07:51:04 -0500 | [diff] [blame] | 28 | ioc.stop(); |
| 29 | }); |
Krzysztof Grobelny | 64b75a5 | 2020-09-18 10:17:16 +0200 | [diff] [blame] | 30 | |
| 31 | phosphor::logging::log<phosphor::logging::level::INFO>( |
| 32 | "Telemetry starting"); |
| 33 | Telemetry app(bus); |
| 34 | ioc.run(); |
| 35 | |
| 36 | return 0; |
| 37 | } |