29 DEFINE_int32(http_port, 11000,
"Port to listen on with HTTP protocol");
30 DEFINE_int32(spdy_port, 11001,
"Port to listen on with SPDY protocol");
31 DEFINE_int32(h2_port, 11002,
"Port to listen on with HTTP/2 protocol");
34 "will use the number of cores on this machine.");
55 gflags::ParseCommandLineFlags(&argc, &argv,
true);
56 google::InitGoogleLogging(argv[0]);
57 google::InstallFailureSignalHandler();
59 std::vector<HTTPServer::IPConfig> IPs = {
60 {
SocketAddress(FLAGS_ip, FLAGS_http_port,
true), Protocol::HTTP},
61 {
SocketAddress(FLAGS_ip, FLAGS_spdy_port,
true), Protocol::SPDY},
62 {
SocketAddress(FLAGS_ip, FLAGS_h2_port,
true), Protocol::HTTP2},
65 if (FLAGS_threads <= 0) {
66 FLAGS_threads = sysconf(_SC_NPROCESSORS_ONLN);
67 CHECK(FLAGS_threads > 0);
71 options.
threads =
static_cast<size_t>(FLAGS_threads);
72 options.
idleTimeout = std::chrono::milliseconds(60000);
84 std::thread
t([&] () {
RequestHandler * onRequest(RequestHandler *, HTTPMessage *) noexceptoverride
void onServerStart(folly::EventBase *) noexceptoverride
void start(std::function< void()> onSuccess=nullptr, std::function< void(std::exception_ptr)> onError=nullptr)
void onServerStop() noexceptoverride
std::chrono::milliseconds idleTimeout
constexpr detail::Map< Move > move
void bind(std::vector< IPConfig > &&addrs)
RequestHandlerChain & addThen(Args &&...args)
requires E e noexcept(noexcept(s.error(std::move(e))))
DEFINE_int32(http_port, 11000,"Port to listen on with HTTP protocol")
std::vector< std::thread::id > threads
std::vector< std::unique_ptr< RequestHandlerFactory > > handlerFactories
DEFINE_string(ip,"localhost","IP/Hostname to bind to")
HTTPServer::Protocol Protocol
folly::ThreadLocalPtr< EchoStats > stats_
std::vector< int > shutdownOn
int main(int argc, char *argv[])
bool enableContentCompression