YLombardi YLombardi - 4 months ago 37
Linux Question

Spring boot application as a service + VM Options

I have a Spring boot application that is started as a service using Linux's systemd.

It is based on this documentation :
http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html

With the default script, the jar file start. It works fine.

/etc/systemd/system/myapp.service :

[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=/var/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target


Now I want to add VM Option when the jar start.
I tried to add a .conf file to the project but it doesn't work.

/var/myapp/myapp.conf :

JAVA_OPTS=-Xms256M -Xmx512M


How can I add JVM option to start the application with systemd ?

Answer

I finally found a solution here : how to configure heap size when start a spring-boot application with embedded tomcat?

The content of my .conf file was wrong. I need too write this :

export JAVA_OPTS="-Xms256m -Xmx512m"

Now when I run "service myapp start", it start with the good heap size.