diff --git a/README.md b/README.md index 7b537cd..c0c6294 100644 --- a/README.md +++ b/README.md @@ -31,21 +31,13 @@ version="1.12.2" 5. Select how much memory you want your server to use ***(in megabytes)***: ```bash -initMem="1500M" #1.5G -maxMem="8000M" # 12G +mem="8000M" ``` -6. Modify server parameters to your liking: - ```bash -mc_launchoptions="-nogui" -``` +6. Allow executing ov the script with `chmod +x start.sh` +7. Run the script with `./start.sh` -7. Add some jvm (java) parameters to your liking ***(memory is set above, do not add it here)***: - ```bash - java_launchoptions="" - ``` - > **Note** - > - > If you use quite old versions of minecraft you should change the defaults under the line above - -8. Run the script with `./start.sh` +## Default JVM flags used + +By default this script uses [Aikar's Flags](https://docs.papermc.io/paper/aikars-flags). It's set up so that it automatically modifies them if over +12GB of memory is set for the server so you shouldn't need to change them unless you want to swap them out for something else. diff --git a/start.sh b/start.sh index cd12af6..bf3acf1 100644 --- a/start.sh +++ b/start.sh @@ -4,6 +4,7 @@ # by jiriks74 # # https://github.com/jiriks74/start_papermc.sh # # This script is under GPLv3, if you want to distribute changes you have to do so under the same license # +# and acknowledge the original script and author. # ############################################################################################################# ############ @@ -16,32 +17,50 @@ # and change the version below. # # I am not responsible for any loss of data # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # -# If enough people request it (or someone creates a PR) I'll add this functionality +# If enough people request it (or someone creates a PR) I'll add the functionality to migrate versions version="1.19.3" -# Leave blank to use the latest build +# Leave blank to use the latest build (auto updates on every run) select_build="" +# # Memory settings -initMem="2000M" # Minimum memory used -maxMem="6000M" # Maximum memory allowed to be used +# +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # +# Do not allocate all of your available memory on a shared host! # +# Minecraft (and Java) needs to have more memory than the Xmx # +# parameter (maxMem below). You should set it at least 1500M # +# lower than your available memory if you're running just the # +# minecraft server. # +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # +mem="2000M" + + + +# ------------------------------------------------ +# You shouldn't need to change anything below this +# ------------------------------------------------ # Options for the server mc_launchoptions="-nogui" -# G1GC settings - leave the defaults if you're unsure -g1HeapMem="32M" # Memory used by G1 -g1NewSize="20" # In % -g1Reserve"20" # In % -umaxGCpause="50" # In millis +if [[ "${mem%M}" -gt 12000 ]]; then + G1NewSize=40 + G1MaxNewSize=50 + G1HeapRegionSize=16M + G1Reserve=15 + InitiatingHeapOccupancy=20 +else + G1NewSize=30 + G1MaxNewSize=40 + G1HeapRegionSize=8M + G1Reserve=20 + InitiatingHeapOccupancy=15 +fi -# Aditional options for the java runtime -java_launchoptions="" +# Aikar's flags are used by default +# See https://docs.papermc.io/paper/aikars-flags +java_launchoptions="-Xms$mem -Xmx$mem -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=$G1NewSize -XX:G1MaxNewSizePercent=$G1MaxNewSize -XX:G1HeapRegionSize=$G1HeapRegionSize -XX:G1ReservePercent=$G1Reserve -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=$InitiatingHeapOccupancy -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" -# Change the defaults if you use older version of minecraft or just want to use something else -java_launchoptions="-Xms$initMem -Xmx$maxMem -XX:G1HeapRegionSize=$g1HeapMem -XX:+UseG1GC -XX:G1NewSizePercent=$g1NewSize -XX:G1ReservePercent=$g1Reserve -XX:MaxGCPauseMillis=$maxGCpause $java_launchoptions" - -# You shouldn't need to change anything below this line -# ----------------------------------------------------- # Api url url="https://api.papermc.io/v2/projects/paper/versions/$version/builds"