Skip to content
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

Allow to configure StartMojo's wait and maxAttempts attributes from the command-line #26422

Closed
wants to merge 2 commits into from

Conversation

marcus-nl
Copy link
Contributor

This allows overriding the settings for the Maven StartMojo (spring-boot:start) from the command line, most notably wait and maxAttempts, but also the other missing ones and for StopMojo as well. It is useful to increase the timeout on an CI environment, where it can take a longer time to start than usual. I've also moved the default values to the @Parameter annotation, so that these show up in the documentation.

@pivotal-cla
Copy link

@marcus-nl Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@marcus-nl Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 11, 2021
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I don't think that all properties of a goal should be exposed, in particular when a certain consistency is requested as it is the case here.

It is useful to increase the timeout on an CI environment, where it can take a longer time to start than usual.

No doubt that exposing that via a property is useful but you can achieve that too by configuring the plugin with a property of your own and set that property in your CI environment.

I am, in particular, not keen to expose separate properties for thing that must have the same value. Thoughts?


/**
* The port to use to expose the platform MBeanServer if the application is forked.
*/
@Parameter
private int jmxPort = 9001;
@Parameter(property = "spring-boot.start.jmxPort", defaultValue = "9001")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JMX port that is used to start and stop the app can't be different so exposing two properties for this doesn't feel right to me.

@@ -61,29 +61,29 @@
* The JMX name of the automatically deployed MBean managing the lifecycle of the
* spring application.
*/
@Parameter
private String jmxName = SpringApplicationAdminClient.DEFAULT_OBJECT_NAME;
@Parameter(property = "spring-boot.start.jmxName", defaultValue = SpringApplicationAdminClient.DEFAULT_OBJECT_NAME)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the JMX name that is used to start and stop the app can't be different so exposing two properties for this doesn't feel right to me.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label May 11, 2021
@marcus-nl
Copy link
Contributor Author

marcus-nl commented May 11, 2021

Hi @snicoll, Thanks for the feedback.

No doubt that exposing that via a property is useful but you can achieve that too by configuring the plugin with a property of your own and set that property in your CI environment.

True, but doesn't that apply to every configuration option? I think the timeout settings are particularly good candidates to give their own properties because their values may quite realistically differ in different circumstances. Not having to change the pom.xml (even to add your own property) makes it a lot more convenient.

I am, in particular, not keen to expose separate properties for thing that must have the same value. Thoughts?

You are right. Alternative combined names could be something like "spring-boot.management.jmxName" (/Port) or "spring-boot.jmx.name" (port)? Or just leave them propertly-less, since these seem less likely to need customization. I would suggest keeping the default values in the annotation though, so they show up in the generated documentation.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 11, 2021
@snicoll
Copy link
Member

snicoll commented May 11, 2021

Thanks for the quick follow-up.

True, but doesn't that apply to every configuration option? I think the timeout settings are particularly good candidates to give their own properties because their values may quite realistically differ in different circumstances. Not having to change the pom.xml (even to add your own property) makes it a lot more convenient.

Agreed. The core of my review is that we shouldn't expose all properties. I agree those are good candidates.

Alternative combined names could be something like "spring-boot.management.jmxName" (/Port) or "spring-boot.jmx.name" (port)? Or just leave them propertly-less, since these seem less likely to need customization. I would suggest keeping the default values in the annotation though, so they show up in the generated documentation.

We don't really have any other use cases like this so I'd rather not expose it at all if we can. The default values is good feedback and should be done regardless.

Would you have the time to update your PR in that direction if you agree?

…es. Keep default values for Start/StopMojo's jmxName and jmsPort in @parameter.
@marcus-nl
Copy link
Contributor Author

Done

@snicoll snicoll added type: enhancement A general enhancement and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels May 11, 2021
@snicoll snicoll added this to the 2.6.x milestone May 11, 2021
@snicoll snicoll changed the title Add missing properties and default values to Start- and StopMojo Allow to configure StartMojo's wait and maxAttempts attributes from the command-line May 11, 2021
@philwebb philwebb changed the title Allow to configure StartMojo's wait and maxAttempts attributes from the command-line Allow to configure StartMojo's wait and maxAttempts attributes from the command-line May 13, 2021
@snicoll snicoll self-assigned this May 31, 2021
snicoll pushed a commit to snicoll/spring-boot that referenced this pull request May 31, 2021
snicoll added a commit to snicoll/spring-boot that referenced this pull request May 31, 2021
@snicoll snicoll modified the milestones: 2.6.x, 2.6.0-M1 Jun 1, 2021
snicoll pushed a commit that referenced this pull request Jun 12, 2021
snicoll added a commit that referenced this pull request Jun 12, 2021
@snicoll snicoll closed this in c52eaba Jun 12, 2021
@snicoll
Copy link
Member

snicoll commented Jun 12, 2021

@marcus-nl thank you for making your first contribution to Spring Boot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants