3
votes

I have a Spring Boot project that I'm running as an executable jar started as an init.d service on Linux.

I understand I can create a .conf file with the same name as the jar file to specify JVM parameters. However, I would ideally like to "hard code" some parameters so there is no risk of the .conf file being missing. This is a real risk as each deployment will have a different jar name because of the version number.

Also I know I can set the environment variable JAVA_OPTS, but I'm not sure how to do this if I'm launching the Spring Boot as a init.d service using a symlink to the jar file.

Lastly I know I can replace the init.d script completely using the embeddedLaunchScript parameter, but I fell this overkill for what I want to accomplish and would want updates to the script in further releases.

Is there a way to specify JVM parameters in the Maven plugin or some other programmatic method?

Alternatively is there a way to hard code a static CONF file name? Looking at the embeddedLaunchScriptProperties it looks like confFolder can the folder, but not the name of the .conf file.

1
I think I have a full understanding of options, but want to make sure I'm not missing something before entering a feature request for improving the Maven plugin to allow JVM parameters to be passed through to the embeddedLaunchScript - ThanksJustinKSU
I think this answer is a solution for your problem: serverfault.com/a/462073ahjaworski
If I understand that answer, it involves creating a custom script and making that script a service using init.d I understand that is an option but end goal is deploy the file with the parameters, so the embeddedLaunchScript is equivalent to that answer.JustinKSU
Found some commentary on this request github.com/spring-projects/spring-boot/issues/2797JustinKSU
FYI, github.com/spring-projects/spring-boot/issues/2797 has been re-opened and I'm implementing the solution. I'll put the answer when it is available in a release.JustinKSU

1 Answers

0
votes

As of Spring boot 2.0, you can set the inlinedConfScript property of the build plugin. You can now reference a file that includes the appending or overwriting the JAVA_OPTS variable before the application starts. More details can be found in the Spring Documentation.