From 0ea7bccadb306c841df669e45234210918a360f3 Mon Sep 17 00:00:00 2001 From: LSmyrnaios Date: Sat, 29 Apr 2023 17:55:03 +0300 Subject: [PATCH] Leave the Max-Heap-Size to 8Gb, we assume that enough swap space will be available on the host. We can still override the max-heap-size if desired. --- createSwapStorage.sh | 4 ++-- installAndRun.sh | 16 ++++++++++------ .../controllers/GeneralController.java | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/createSwapStorage.sh b/createSwapStorage.sh index 6a79c98..51be9d8 100755 --- a/createSwapStorage.sh +++ b/createSwapStorage.sh @@ -3,8 +3,8 @@ # Info found in: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04 -# Creating a Swap File with 2 Gb -sudo fallocate -l 2G /swapfile +# Creating a Swap File with 6 Gb +sudo fallocate -l 6G /swapfile ls -lh /swapfile # Enabling the Swap File diff --git a/installAndRun.sh b/installAndRun.sh index 8ff3fb6..737bac0 100755 --- a/installAndRun.sh +++ b/installAndRun.sh @@ -24,6 +24,8 @@ fi gradleVersion="8.1.1" +shouldBeCarefulWithMaxHeap=0 # This is NOT a cmd-arg. + if [[ justRun -eq 0 ]]; then if [[ avoidReInstallingPublicationsRetriever -eq 1 ]]; then @@ -69,12 +71,14 @@ if [[ justRun -eq 0 ]]; then export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH - # Update the max-heap-size based on the machine's physical memory. - machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB. - max_heap_size_mb=$(echo "($machine_memory_mb - 800)/1" | bc) # Leave 800 MB to the system (the "()/1" is used to take the floor value). - # Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m" - echo -e "\n\nThe max-heap-size (-Xmx) will be set to: ${max_heap_size_mb}m\n\n" - sed -i "s/'-Xmx[0-9]\+[gm]'/'-Xmx${max_heap_size_mb}m'/g" ./build.gradle + if [[ shouldBeCarefulWithMaxHeap -eq 1 ]]; then + # Update the max-heap-size based on the machine's physical memory. + machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB. + max_heap_size_mb=$(echo "($machine_memory_mb - 800)/1" | bc) # Leave 800 MB to the system (the "()/1" is used to take the floor value). + # Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m" + echo -e "\n\nThe max-heap-size (-Xmx) will be set to: ${max_heap_size_mb}m\n\n" + sed -i "s/'-Xmx[0-9]\+[gm]'/'-Xmx${max_heap_size_mb}m'/g" ./build.gradle + fi gradle wrapper --gradle-version=${gradleVersion} --distribution-type=bin diff --git a/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java b/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java index 1717ad4..6724b12 100644 --- a/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java +++ b/src/main/java/eu/openaire/urls_worker/controllers/GeneralController.java @@ -55,7 +55,6 @@ public class GeneralController { shouldShutdownWorker = true; finalMsg += " The worker will shutdown, after finishing current work."; - logger.info(initMsg + finalMsg); return ResponseEntity.ok().body(finalMsg + "\n"); }