VEuPathDB / example-jaxrs-container-service

Demo of a containerized Raml & JaxRS based service project.
Apache License 2.0
0 stars 0 forks source link

jvm args environment var #8

Closed rbelnap closed 2 years ago

rbelnap commented 2 years ago

We need a way to set jvm args, most notably -XX:ExitOnOutOfMemoryError

Foxcapades commented 2 years ago

Added 3 env vars to the example repo:

$XMX controls the JVM -Xmx argument. Defaults to 512M $XMS controls the JVM -Xms argument. Defaults to 64M $JVM_ARGS additional arbitrary JVM args.

Additionally added the flag to die on OOM errors.

ryanrdoherty commented 2 years ago

@Foxcapades I wonder if we would benefit from adding this flag also, to help understand from the logs what we were dealing with. It prints out the heap sizes (and other information) chosen by the JVM based on current system information:

-XX:+PrintCommandLineFlags

@rbelnap Is there a benefit to NOT specifying Xmx/Xms specific defaults? Seems like the JVM will pick values based on available resources if not specified. I guess that is less predictable. Any reason to choose that instead?

ryanrdoherty commented 2 years ago

I guess I'm wondering if we should just stick with this, and roll any memory config into the generalized JVM_ARGS param?

ENV JAVA_HOME=/opt/jdk \
    PATH=/opt/jdk/bin:$PATH \
    JVM_ARGS=""

COPY --from=prep /jlinked /opt/jdk
COPY --from=prep /workspace/build/libs/service.jar /service.jar

CMD java -jar -XX:+CrashOnOutOfMemoryError $JVM_ARGS /service.jar