#!/bin/bash set -ex # Caluclate Memory Limit from cgroups/maxmemory MEMSIZE=$(grep MemTotal /proc/meminfo | awk '{print $2 * 1024}') if [ -f "/sys/fs/cgroup/memory/memory.limit_in_bytes" ]; then MEMLIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes) elif [ -f "/sys/fs/cgroup/memory.max" ]; then MEMLIMIT=$(cat /sys/fs/cgroup/memory.max) else MEMLIMIT=$(grep MemTotal /proc/meminfo | awk '{print $2 * 1024}') fi if ! [[ $MEMLIMIT =~ ^[0-9]+$ ]]; then MEMLIMIT=$MEMSIZE fi MEMLIMIT=$((MEMLIMIT /server/eula.txt cat eula.txt java -Xms$SERVER_MEM -Xmx$SERVER_MEM -XX:+UseG1GC \ -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 \ -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC \ -XX:+AlwaysPreTouch -XX:G1NewSizePercent=$G1NEWSIZE \ -XX:G1MaxNewSizePercent=$G1MAXNEWSIZE -XX:G1HeapRegionSize=$G1HEAP \ -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 \ -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 \ -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \ -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 \ -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true \ -jar server.jar