Browse Source

simplify main, also print more information

master
Jørgen Lien Sellæg 9 years ago
parent
commit
dff2e05342
  1. 48
      toREST/src/main.cxx

48
toREST/src/main.cxx

@ -87,33 +87,43 @@ int main(int argc, char *argv[]) {
tr::ws::on_close(session, connection, status, reason);
};
{
std::thread http_thread([&http_server]() {
http_server.start();
});
std::thread http_thread([&http_server]() {
http_server.start();
});
std::cout << "HTTP/1.1 server listening on port " << config.http_port << std::endl;
std::cout << "HTTP/1.1 server listening on port " << config.http_port << std::endl;
std::thread ws_thread([&ws_server]() {
ws_server.start();
});
std::thread ws_thread([&ws_server]() {
ws_server.start();
});
std::cout << "HTTP/1.1 websocket server listening on port " << config.ws_port << std::endl;
std::cout << "HTTP/1.1 websocket server listening on port " << config.ws_port << std::endl;
std::string input;
std::string input;
while (input != "q") {
std::getline(std::cin, input);
if (input == "q") {
std::cout << "Stopping server..." << std::endl;
http_server.stop(); // TODO check if throws
ws_server.stop();
std::cout << "Server stopped" << std::endl;
break;
while (input != "q") {
std::getline(std::cin, input);
}
std::cout << "stopping http server..." << std::endl;
http_server.stop();
std::cout << "stopping ws server..." << std::endl;
ws_server.stop();
http_thread.join();
std::cout << "the http server was stopped." << std::endl;
ws_thread.join();
std::cout << "the ws server was stopped." << std::endl;
}
std::cout << "stopping torrents..." << std::endl;
{
auto session_proxy = session.abort();
}
http_thread.join();
ws_thread.join();
std::cout << "the torrent session was stopped." << std::endl;
return 0;
};

Loading…
Cancel
Save