Created
June 23, 2020 22:15
-
-
Save lukaszkorecki/13944077931b8a54a3d69f996b7d1b32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -oe pipefail | |
jarPath=$1 | |
# inspired by metabase | |
# Disable limit to amount of time spent in GC. Better slow than not working at all | |
JAVA_OPTS="$JAVA_OPTS -XX:-UseGCOverheadLimit" | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC" | |
JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled" | |
# Use 32-bit pointers. Reduces memory usage and GC events | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops" | |
JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedClassPointers" | |
# Heap settings, as dicated by the container memory limits | |
# max and min heap set to X% of what container gives us | |
# by default it's 70%, can be overriden via HEAP_PERCENTAGE env var | |
HEAP_PERCENTAGE=${HEAP_PERCENTAGE:-70} | |
JAVA_OPTS="$JAVA_OPTS -XX:InitialRAMPercentage=${HEAP_PERCENTAGE}" | |
JAVA_OPTS="$JAVA_OPTS -XX:MaxRAMPercentage=${HEAP_PERCENTAGE}" | |
# don't try to start AWT. Not sure this does anything but better safe than wasting memor | |
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true" | |
# always UTF | |
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" | |
# always assume UTC | |
JAVA_OPTS="$JAVA_OPTS -Duser.timezone=UTC" | |
echo "Starting $jarPath" | |
java $JAVA_OPTS -jar $jarPath 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment