in tchannel-crossdock/src/main/java/com/uber/tchannel/crossdock/HTTPServer.java [98:125]
public void run() {
EventLoopGroup bossGroup = new NioEventLoopGroup();
EventLoopGroup workerGroup = new NioEventLoopGroup();
try {
ServerBootstrap b = new ServerBootstrap();
b.group(bossGroup, workerGroup)
.channel(NioServerSocketChannel.class)
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ch.pipeline().addLast("codec", new HttpServerCodec());
ch.pipeline().addLast("aggegator", new HttpObjectAggregator(Integer.MAX_VALUE));
ch.pipeline().addLast("harness", new HealthHandler());
}
})
.option(ChannelOption.SO_BACKLOG, 128)
.childOption(ChannelOption.SO_KEEPALIVE, true);
ChannelFuture f = b.bind("0.0.0.0", port).sync();
f.channel().closeFuture().sync();
} catch (Exception e) {
logger.error("Exception in HTTP server", e);
} finally {
workerGroup.shutdownGracefully();
bossGroup.shutdownGracefully();
}
}