Skip to content

How to wait for HTTP port listening during app start? #13008

Answered by ihostage
Rotkaf asked this question in Q&A
Discussion options

You must be logged in to vote

Can you try to block initialization of your ApplicationStart component?

wsService.someRequest().thenAccept(jsonNode -> utils.putDataInCache())
  .toCompletableFuture().get();

It's not a good solution, but can help in your case, because application will wait initialization your component before listen port and handle requests.

PS: Also as an example of this approach you can see Play Flyway plugin. This plugin does database migration before start an application. It also use eager component with blocked initialization to make all migrations before handle user request.

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ihostage
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants