proxygen
PushServer.cpp File Reference

Go to the source code of this file.

Classes

class  PushRequestHandlerFactory
 

Typedefs

using Protocol = HTTPServer::Protocol
 

Functions

 DEFINE_int32 (http_port, 11000,"Port to listen on with HTTP protocol")
 
 DEFINE_int32 (spdy_port, 11001,"Port to listen on with SPDY protocol")
 
 DEFINE_int32 (h2_port, 11002,"Port to listen on with HTTP/2 protocol")
 
 DEFINE_string (ip,"localhost","IP/Hostname to bind to")
 
 DEFINE_int32 (threads, 0,"Number of threads to listen on. Numbers <= 0 ""will use the number of cores on this machine.")
 
int main (int argc, char *argv[])
 

Typedef Documentation

Definition at line 27 of file PushServer.cpp.

Function Documentation

DEFINE_int32 ( http_port  ,
11000  ,
"Port to listen on with HTTP protocol"   
)
DEFINE_int32 ( spdy_port  ,
11001  ,
"Port to listen on with SPDY protocol"   
)
DEFINE_int32 ( h2_port  ,
11002  ,
"Port to listen on with HTTP/2 protocol"   
)
DEFINE_int32 ( threads  ,
,
"Number of threads to listen on. Numbers <= 0 ""will use the number of cores on this machine."   
)
DEFINE_string ( ip  ,
"localhost"  ,
"IP/Hostname to bind to"   
)
int main ( int  argc,
char *  argv[] 
)

Definition at line 54 of file PushServer.cpp.

References proxygen::RequestHandlerChain::addThen(), proxygen::HTTPServer::bind(), proxygen::HTTPServerOptions::enableContentCompression, proxygen::HTTPServerOptions::handlerFactories, proxygen::HTTPServerOptions::idleTimeout, folly::gen::move, proxygen::HTTPServerOptions::shutdownOn, proxygen::HTTPServer::start(), folly::pushmi::detail::t, and proxygen::HTTPServerOptions::threads.

54  {
55  gflags::ParseCommandLineFlags(&argc, &argv, true);
56  google::InitGoogleLogging(argv[0]);
57  google::InstallFailureSignalHandler();
58 
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},
63  };
64 
65  if (FLAGS_threads <= 0) {
66  FLAGS_threads = sysconf(_SC_NPROCESSORS_ONLN);
67  CHECK(FLAGS_threads > 0);
68  }
69 
70  HTTPServerOptions options;
71  options.threads = static_cast<size_t>(FLAGS_threads);
72  options.idleTimeout = std::chrono::milliseconds(60000);
73  options.shutdownOn = {SIGINT, SIGTERM};
74  options.enableContentCompression = true;
77  .build();
78 
79  HTTPServer server(std::move(options));
80  server.bind(IPs);
81 
82  // Start HTTPServer mainloop in a separate thread
83  std::thread t([&] () {
84  server.start();
85  });
86 
87  t.join();
88  return 0;
89 }
std::chrono::milliseconds idleTimeout
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
RequestHandlerChain & addThen(Args &&...args)
char ** argv
std::vector< std::unique_ptr< RequestHandlerFactory > > handlerFactories
std::vector< int > shutdownOn