Author SHA1 Message Date
Tobias Schöneberg afdc48d2d7 41-docker - Allow us to obtain java heap-dumps in case of an OutOfMemoryError
* add MaxRAMFraction so java uses the docker image's memory completely (and not just 1/4)

https://github.com/metasfresh/metasfresh-docker/issues/41
2019-01-23 10:44:48 +01:00
Tobias Schöneberg b8af7dd9e8 41-docker - Allow us to obtain java heap-dumps in case of an OutOfMemoryError
* add dedicated volumes for app and webapi
* bonus: derive memory settings from docker instead of setting them statically

https://github.com/metasfresh/metasfresh-docker/issues/41
2019-01-22 13:17:13 +01:00
4 changed files with 32 additions and 2 deletions
+8 -1
View File
@@ -6,6 +6,7 @@ set -u
DB_HOST=db
APP_HOST=app
set_properties()
{
local prop_file="$1"
@@ -53,9 +54,15 @@ run_metasfresh()
# info: https://docs.oracle.com/cd/E26362_01/E40761/html/known-bugs-issues.html
# https://stackoverflow.com/a/19379760
# thx to
# https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed/
MEMORY_PARAMS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1"
cd /opt/metasfresh/ && java \
-Dsun.misc.URLClassPath.disableJarChecking=true \
-Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError \
$MEMORY_PARAMS \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/metasfresh/heapdump \
-DPropertyFile=/opt/metasfresh/metasfresh.properties \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8788 \
-Dcom.sun.net.ssl.enableECC=false \
+2
View File
@@ -18,6 +18,7 @@ app:
restart: always
volumes:
- ./volumes/app/log:/opt/metasfresh/log:rw
- ./volumes/app/heapdump:/opt/metasfresh/heapdump:rw
- /etc/localtime:/etc/localtime:ro
environment:
- METASFRESH_HOME=/opt/metasfresh
@@ -29,6 +30,7 @@ webapi:
restart: always
volumes:
- ./volumes/webapi/log:/opt/metasfresh-webui-api/log:rw
- ./volumes/webapi/heapdump:/opt/metasfresh-webui-api/heapdump:rw
- /etc/localtime:/etc/localtime:ro
webui:
build: webui
+2
View File
@@ -22,6 +22,7 @@ services:
restart: always
volumes:
- ./volumes/app/log:/opt/metasfresh/log:rw
- ./volumes/app/heapdump:/opt/metasfresh/heapdump:rw
- /etc/localtime:/etc/localtime:ro
environment:
- METASFRESH_HOME=/opt/metasfresh
@@ -33,6 +34,7 @@ services:
restart: always
volumes:
- ./volumes/webapi/log:/opt/metasfresh-webui-api/log:rw
- ./volumes/webapi/heapdump:/opt/metasfresh-webui-api/heapdump:rw
- /etc/localtime:/etc/localtime:ro
webui:
+20 -1
View File
@@ -1,10 +1,23 @@
#!/bin/bash
set -e
#set -x
DB_HOST=db
APP_HOST=app
echo_variable_values()
{
echo "*************************************************************"
echo "Display the variable values we run with"
echo "*************************************************************"
echo "Note: all these variables can be set using the -e parameter."
echo ""
echo "DB_HOST=${DB_HOST}"
echo "APP_HOST=${APP_HOST}"
echo ""
}
set_properties()
{
local prop_file="$1"
@@ -22,10 +35,15 @@ wait_dbms()
done
}
# thx to
# https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed/
MEMORY_PARAMS="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1"
run_metasfresh()
{
cd /opt/metasfresh-webui-api/ && java -Dsun.misc.URLClassPath.disableJarChecking=true \
-Xmx1024M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError \
$MEMORY_PARAMS \
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/metasfresh-webui-api/heapdump \
-DPropertyFile=/opt/metasfresh-webui-api/metasfresh.properties \
-Dcom.sun.management.jmxremote.port=1618 \
-Dcom.sun.management.jmxremote.authenticate=false \
@@ -34,6 +52,7 @@ run_metasfresh()
-jar metasfresh-webui-api.jar
}
echo_variable_values
set_properties /opt/metasfresh-webui-api/metasfresh.properties
set_properties /opt/metasfresh-webui-api/local_settings.properties