29 DEFINE_int32(http_port, 11000,
"Port to listen on with HTTP protocol");
30 DEFINE_int32(h2_port, 11002,
"Port to listen on with HTTP/2 protocol");
33 "will use the number of cores on this machine.");
35 "How long to wait for a server response (sec)");
41 timer_->timer = HHWheelTimer::newTimer(
43 std::chrono::milliseconds(HHWheelTimer::DEFAULT_TICK_INTERVAL),
45 std::chrono::seconds(FLAGS_server_timeout));
66 gflags::ParseCommandLineFlags(&argc, &argv,
true);
67 google::InitGoogleLogging(argv[0]);
68 google::InstallFailureSignalHandler();
70 std::vector<HTTPServer::IPConfig> IPs = {
71 {
SocketAddress(FLAGS_ip, FLAGS_http_port,
true), Protocol::HTTP},
72 {
SocketAddress(FLAGS_ip, FLAGS_h2_port,
true), Protocol::HTTP2},
75 if (FLAGS_threads <= 0) {
76 FLAGS_threads = sysconf(_SC_NPROCESSORS_ONLN);
77 CHECK(FLAGS_threads > 0);
81 options.
threads =
static_cast<size_t>(FLAGS_threads);
82 options.
idleTimeout = std::chrono::milliseconds(60000);
95 std::thread
t([&] () {
folly::ThreadLocal< TimerWrapper > timer_
void start(std::function< void()> onSuccess=nullptr, std::function< void(std::exception_ptr)> onError=nullptr)
std::chrono::milliseconds idleTimeout
constexpr detail::Map< Move > move
int main(int argc, char *argv[])
void bind(std::vector< IPConfig > &&addrs)
RequestHandlerChain & addThen(Args &&...args)
requires E e noexcept(noexcept(s.error(std::move(e))))
stop_watch< std::chrono::milliseconds > timer_
void onServerStart(folly::EventBase *evb) noexceptoverride
std::vector< std::thread::id > threads
folly::ThreadLocalPtr< ProxyStats > stats_
HHWheelTimer::UniquePtr timer
RequestHandler * onRequest(RequestHandler *, HTTPMessage *) noexceptoverride
std::vector< std::unique_ptr< RequestHandlerFactory > > handlerFactories
DEFINE_int32(http_port, 11000,"Port to listen on with HTTP protocol")
DEFINE_string(ip,"localhost","IP/Hostname to bind to")
std::vector< int > shutdownOn
void onServerStop() noexceptoverride
HTTPServer::Protocol Protocol
bool enableContentCompression