rebase websocketserverasync

This commit is contained in:
Nathan Nichols
2021-06-14 09:35:56 -05:00
committed by CJ Cobb
parent 2a09a68f60
commit 7860ec6cd1

View File

@@ -111,19 +111,18 @@ int
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
// Check command line arguments. // Check command line arguments.
if (argc != 5 and argc != 6) if (argc != 3 and argc != 4)
{ {
std::cerr std::cerr
<< "Usage: websocket-server-async <address> <port> <threads> " << "Usage: websocket-server-async <threads> "
"<config_file> <log level> \n" "<config_file> <log level> \n"
<< "Example:\n" << "Example:\n"
<< " websocket-server-async 0.0.0.0 8080 1 config.json 2\n"; << " websocket-server-async 1 config.json 2\n";
return EXIT_FAILURE; return EXIT_FAILURE;
} }
auto const address = boost::asio::ip::make_address(argv[1]);
auto const port = static_cast<unsigned short>(std::atoi(argv[2])); auto const threads = std::max<int>(1, std::atoi(argv[1]));
auto const threads = std::max<int>(1, std::atoi(argv[3])); auto const config = parse_config(argv[2]);
auto const config = parse_config(argv[4]);
if (argc > 5) if (argc > 5)
{ {
initLogLevel(std::atoi(argv[5])); initLogLevel(std::atoi(argv[5]));
@@ -138,7 +137,6 @@ main(int argc, char* argv[])
return EXIT_FAILURE; return EXIT_FAILURE;
} }
// The io_context is required for all I/O
boost::asio::io_context ioc{threads}; boost::asio::io_context ioc{threads};
DOSGuard dosGuard{config.value(), ioc}; DOSGuard dosGuard{config.value(), ioc};