From f310c094cb425e9a9db4e9052ad71782a6e74be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:33:38 +0100 Subject: [PATCH 1/6] Add Aikar's flags as a default --- start.sh | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/start.sh b/start.sh index cd12af6..747b9ef 100644 --- a/start.sh +++ b/start.sh @@ -22,27 +22,42 @@ version="1.19.3" 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="6000M" +# If you're using more memory than 12GB uncomment the line below +# over_12G=true # 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 - -# Aditional options for the java runtime -java_launchoptions="" - -# 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 # ----------------------------------------------------- +if [ "$over_12G" = true ]; then + G1NewSize=40 + G1MaxNewSize=50 + G1HeapRegionSize=16M + G1Reserve=15 + InitiatingHeapOccupancy=20 +else + G1NewSize=30 + G1MaxNewSize=40 + G1HeapRegionSize=8M + G1Reserve=20 + InitiatingHeapOccupancy=15 +fi + +# 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" + + # Api url url="https://api.papermc.io/v2/projects/paper/versions/$version/builds" From c4a3db4fa3e787c2a009d69d861971a08782e946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:42:44 +0100 Subject: [PATCH 2/6] Flags for over 12G of memory changed If more than 12G of memory was allocated different flags will be used Some comments polished --- start.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index 747b9ef..cdc35eb 100644 --- a/start.sh +++ b/start.sh @@ -16,12 +16,14 @@ # 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 +# # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # Do not allocate all of your available memory on a shared host! # # Minecraft (and Java) needs to have more memory than the Xmx # @@ -29,17 +31,18 @@ select_build="" # lower than your available memory if you're running just the # # minecraft server. # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # -mem="6000M" -# If you're using more memory than 12GB uncomment the line below -# over_12G=true +mem="2000M" + +# # Options for the server +# mc_launchoptions="-nogui" # You shouldn't need to change anything below this line # ----------------------------------------------------- -if [ "$over_12G" = true ]; then +if [[ "${mem%M}" -gt 12000 ]]; then G1NewSize=40 G1MaxNewSize=50 G1HeapRegionSize=16M From 318228fafdf44b791ea2bfeb61451e4908a68924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:43:07 +0100 Subject: [PATCH 3/6] Removed a blank line --- start.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/start.sh b/start.sh index cdc35eb..591f61c 100644 --- a/start.sh +++ b/start.sh @@ -31,7 +31,6 @@ select_build="" # lower than your available memory if you're running just the # # minecraft server. # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # - mem="2000M" # From 0683e98cdf08b7c1cf036e42cd10117fc72bc36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:48:22 +0100 Subject: [PATCH 4/6] Polished comments --- start.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 591f61c..fce3bec 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. # ############################################################################################################# ############ @@ -38,8 +39,9 @@ mem="2000M" # mc_launchoptions="-nogui" -# You shouldn't need to change anything below this line -# ----------------------------------------------------- +# ------------------------------------------------ +# You shouldn't need to change anything below this +# ------------------------------------------------ if [[ "${mem%M}" -gt 12000 ]]; then G1NewSize=40 From a51e3e777d79bb312d44857fb50c2b31d3913c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:50:21 +0100 Subject: [PATCH 5/6] Moved server options below the settings section --- start.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/start.sh b/start.sh index fce3bec..bf3acf1 100644 --- a/start.sh +++ b/start.sh @@ -34,15 +34,15 @@ select_build="" # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # mem="2000M" -# -# Options for the server -# -mc_launchoptions="-nogui" + # ------------------------------------------------ # You shouldn't need to change anything below this # ------------------------------------------------ +# Options for the server +mc_launchoptions="-nogui" + if [[ "${mem%M}" -gt 12000 ]]; then G1NewSize=40 G1MaxNewSize=50 From 336867fef3e2931d4c0f731255278c9a12ce598a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=A0tefka?= Date: Thu, 23 Feb 2023 02:54:06 +0100 Subject: [PATCH 6/6] Update README.md --- README.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) 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.