3

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.

JustinKSU
  • 4,875
  • 2
  • 29
  • 51
  • 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 - Thanks – JustinKSU May 26 '17 at 14:32
  • I think this answer is a solution for your problem: https://serverfault.com/a/462073 – ahjaworski May 26 '17 at 14:35
  • 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 May 26 '17 at 14:42
  • Found some commentary on this request https://github.com/spring-projects/spring-boot/issues/2797 – JustinKSU May 26 '17 at 18:38
  • FYI, https://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 Jun 14 '17 at 14:49
  • [How to use inlinedConfScript to configure JAVA_OPTS with maven?](https://stackoverflow.com/questions/58763182/how-to-use-inlinedconfscript-to-configure-java-opts-with-maven) Hope to get your help! – Kaikang Sun Nov 08 '19 at 08:55
  • Post a question. I think if you remove the leading slash it will work. – JustinKSU Nov 08 '19 at 12:49

1 Answers1

0

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.

JustinKSU
  • 4,875
  • 2
  • 29
  • 51