Support assigning 0 to http/https port for OS assigned port. #414
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enables support for assigning
server.port=0
andserver.port.https=0
and have the OS assign an available port. This is to facilitate testing on CI servers with multiple jobs, allowing Grails to bind to an available port.Tested manually in the following scenarios:
grails -Dserver.port=0 run-app
grails -Dserver.port.https=0 run-app -https
grails -Dserver.port=0 run-war
grails -Dserver.port.https=0 run-war -https
grails -Dserver.port=0 run-app
(with grails.project.fork.run=true)grails -Dserver.port.https=0 run-app -https
(with grails.project.fork.run=true)Notes
server.port - 1
instead of+ 1
. This is because when running both http and https as 0, they will typically be assigned sequential ports which causes the kill switch and https to use the same port.testPhasePrepared
. This executes after Tomcat is initialized and will allow plugins (i.e. Geb) to get the actual server ports (instead of 0).I was hoping that this could go into 2.2.5 since I think there will a number of people who won't be upgrading to 2.3 for a while. This patch should work fine in 2.3.x as well although the changes to the Tomcat plugin will need to be transferred to its repo.