Перехват сигналов

This commit is contained in:
Sithas777 2023-09-13 15:57:22 +03:00
parent f6bfe82e93
commit 8b47facbdd

View File

@ -14,6 +14,7 @@ namespace net = boost::asio;
using namespace std::literals; using namespace std::literals;
namespace sys = boost::system; namespace sys = boost::system;
namespace http = boost::beast::http; namespace http = boost::beast::http;
using namespace std;
// Запрос, тело которого представлено в виде строки // Запрос, тело которого представлено в виде строки
using StringRequest = http::request<http::string_body>; using StringRequest = http::request<http::string_body>;
@ -76,18 +77,25 @@ int main()
{ {
if (!ec) if (!ec)
{ {
cout << "Signal "sv << signal_number << " received"sv << endl;
ioc.stop(); ioc.stop();
} }
}); });
const auto address = net::ip::make_address("0.0.0.0"); const auto address = net::ip::make_address("0.0.0.0");
constexpr constexpr net::ip::port_type port = 8080;
net::ip::port_type port = 8080;
http_server::ServeHttp(ioc, {address, port}, [](auto&& req, auto&& sender) http_server::ServeHttp(ioc, {address, port}, [](auto&& req, auto&& sender)
{ {
// sender(HandleRequest(std::forward<decltype(req)>(req))); // sender(HandleRequest(std::forward<decltype(req)>(req)));
}); });
net::steady_timer t {ioc, 30s};
t.async_wait([](sys::error_code ec)
{
cout << "Timer expired"sv << endl;
});
// Эта надпись сообщает тестам о том, что сервер запущен и готов обрабатывать запросы // Эта надпись сообщает тестам о том, что сервер запущен и готов обрабатывать запросы
std::cout << "Server has started..."sv << std::endl; std::cout << "Server has started..."sv << std::endl;