Skip to content

Commit

Permalink
finatra: Properly log bound address in server startup
Browse files Browse the repository at this point in the history
Problem

The http server doesn't properly log the bound address of the
started listening server such that when the ephemeral port (0)
is used, the logged output still shows the server bound to port
0.

Solution

Ensure we log the bound address of the server and make thrift
server logging (which was logging the raw InetSocketAddress)
to be the same.

Result:

Thrift before:
[main] INFO com.twitter.echo.thrift.EchoThriftServerMain$ - thrift server started on port: /0:0:0:0:0:0:0:0:50058
Thrift after:
[main] INFO com.twitter.echo.thrift.EchoThriftServerMain$ - admin http server started on port 50058

Http before:
[main] INFO com.twitter.echo.http.EchoHttpServerMain$ - http server started on port:  0.0.0.0/0.0.0.0:50084
[main] INFO com.twitter.echo.http.EchoHttpServerMain$ - http server started on port:  0.0.0.0/0.0.0.0:0 (when using the emphermal port)
Http after:
[main] INFO com.twitter.echo.http.EchoHttpServerMain$ - http server started on port 50084

Differential Revision: https://phabricator.twitter.biz/D563758
  • Loading branch information
cacoco authored and jenkins committed Oct 12, 2020
1 parent 0e25ecf commit 4410ff3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -22,6 +22,9 @@ Added
Changed
~~~~~~~

* http: The http server did not properly log the bound address on server startup. Fix this
and make the thrift server consistent. ``PHAB_ID=D563758``

* utils: (BREAKING API CHANGE) Rename `maybeIsCaseClass` to `notCaseClass` in
`ClassUtils` and change the scope of the method. ``PHAB_ID=D556169``

Expand Down
2 changes: 1 addition & 1 deletion http/src/main/scala/com/twitter/finatra/http/servers.scala
Expand Up @@ -316,7 +316,7 @@ trait HttpServerTrait extends TwitterServer {
info(s"http server announced to $addr")
httpServer.announce(addr)
}
info(s"http server started on port: $address")
info(s"http server started on port ${PortUtils.getPort(httpServer.boundAddress)}")
}

// START HTTPS
Expand Down
Expand Up @@ -194,7 +194,7 @@ trait ThriftServerTrait extends TwitterServer {
info(s"thrift server announced to $addr")
thriftServer.announce(addr)
}
info(s"thrift server started on port: ${thriftPort.get}")
info(s"thrift server started on port ${PortUtils.getPort(thriftServer.boundAddress)}")
}

/* Overrides */
Expand Down

0 comments on commit 4410ff3

Please sign in to comment.