)
TARGET_LINK_LIBRARIES(${TARGET_TEF_SIMULATOR_DEBUGPROXY}
- boost_system boost_signals boost_coroutine
+ boost_system boost_signals boost_coroutine pthread
${TARGET_TEF_SIMULATOR_LOG}
${DEBUGPROXY_DEPS_LIBRARIES}
)
public:
DebugproxySocket(boost::asio::io_service &io);
void start_accept();
+ void shutdown();
private:
void async_accept(yield_ctx yield);
void handle_connection(std::shared_ptr<local_sock> local_sock,
yield_ctx yield);
-
boost::asio::io_service &io;
local::stream_protocol::endpoint ep;
local::stream_protocol::acceptor acceptor;
LOGE(MODULE_DEBUGPROXY, "Forwarding session ended: %s", e.what());
}
}
+
+void DebugproxySocket::shutdown()
+{
+ LOGD(MODULE_DEBUGPROXY, "Shutting down gracefully");
+ this->acceptor.cancel();
+ this->acceptor.close();
+}
boost::asio::io_service io;
DebugproxySocket socket(io);
socket.start_accept();
+
+ boost::asio::signal_set graceful_shutdown_sigs(io, SIGTERM);
+ graceful_shutdown_sigs.async_wait(
+ [&socket](const boost::system::error_code &e, int number) {
+ socket.shutdown();
+ });
+
io.run();
return 0;
}