New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded Tomcat container binds port before application is completely started #55
Comments
I don't see a way to get a hold of an |
OK, Mark T showed me how to set the property ( |
I think I may have cracked it - we have to explicitly stop the connector after it has started (e.g. in |
The `Tomcat.start()` has to happen to initialize the `ServletContext` but we can immediately stop the connector and then restart it when the context is finished refreshing. Seems to make curl fail quickly if an app is slow to start.
The `Tomcat.start()` has to happen to initialize the `ServletContext` but we can immediately stop the connector and then restart it when the context is finished refreshing. Seems to make curl fail quickly if an app is slow to start.
The `Tomcat.start()` has to happen to initialize the `ServletContext` but we can immediately stop the connector and then restart it when the context is finished refreshing. Seems to make curl fail quickly if an app is slow to start.
Currently, when an application is starting up, the embedded Tomcat container binds to its port before the application has finished starting. To see this in action, attempt to start a controller that sleeps in a static block. Something like the following:
When you run
spring run app.groovy
, you'll see the console stall before the application has stated completely. However, if you attempt tocurl http://localhost:8080
,curl
will also stall because the port is bound and while no response has been returned, a socket connection can be completed. An alternative test is totelnet localhost 8080
and see if a connection can be made.This is problematic in Cloud Foundry as the HealthManager determines when an application has started by attempted a socket connection to it's provided port. Whether the application is running behind the scenes isn't actually checked, so a false-positive
started
can be returned.The intended behavior should be that when the console is stalled as described above,
curl
should returncurl: (7) couldn't connect to host
indicating that the port hasn't even been bound to yet. This is typically set in the Tomcat configuration usingbindOnInit
. I believe that there is a programmatic equivalent to this configuration parameter.The text was updated successfully, but these errors were encountered: