diff --git a/server/proxy_server/main.cpp b/server/proxy_server/main.cpp index 38a75d936e..247ea4343f 100644 --- a/server/proxy_server/main.cpp +++ b/server/proxy_server/main.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -289,8 +290,25 @@ int main(int argc, char** argv) LOG_DBG << "Start server: " << server_listen; net::io_context ioc(1); + net::signal_set terminator_signal(ioc); server_ptr server; + terminator_signal.add(SIGINT); + terminator_signal.add(SIGTERM); +#ifdef __linux__ + signal(SIGPIPE, SIG_IGN); +#endif +#if defined(SIGQUIT) + terminator_signal.add(SIGQUIT); +#endif // defined(SIGQUIT) + + terminator_signal.async_wait( + [&](const boost::system::error_code&, int sig) mutable + { + terminator_signal.remove(sig); + ioc.stop(); + }); + net::co_spawn(ioc, start_proxy_server(ioc, server), net::detached);