javascalafinagletwitter-finagle

Finagle server dont ready after start


I have a Finagle server which apperently there´s no way to know when is rerally up.

Having this code

esbMockServer = Some(defaultServer
        .serve(s"localhost:$esbPort", esbService))
      println(s"Running Finagle Regular Esb Mock Server in port $esbPort.......")
      Await.ready(esbMockServer.get,10 second)

Always throw a timeout exception in the Await, but it´s up and running properly since second 1.

Any idea what´s wrong here?


Solution

  • Await.ready does not do what you seem to think it does. It's basically the same as Await.result, except that it returns the Awaitable object itself rather than the result.

    The bottom line is, Await.ready will return after the Server is stopped (.close is called on it), not when it is "ready" ... the latter should be the case, pretty much, right away, you don't need to wait for it.

    Typically, you'll want to put Await.ready(server) at the end of your main function to block the main thread forever, until the server exits.