Spring boot application as a service + VM Options

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.


According to the documentation you can simply add an environment variable JAVA_OPTS if that's enough for you.

The way we start the apps with custom ENV variables and systemd would look like this for your project:

[Unit]
Description=myapp
After=syslog.target

[Service]
User=myapp
ExecStart=source /var/myapp/myapp.conf; java -jar /var/myapp/myapp.jar
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target

Basically sourcing the ENV config directly will expose the ENV variables to the application