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.
This commit is contained in:
parent
d5a997ad3d
commit
0ea7bccadb
|
@ -3,8 +3,8 @@
|
||||||
# Info found in: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
|
# 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
|
# Creating a Swap File with 6 Gb
|
||||||
sudo fallocate -l 2G /swapfile
|
sudo fallocate -l 6G /swapfile
|
||||||
ls -lh /swapfile
|
ls -lh /swapfile
|
||||||
|
|
||||||
# Enabling the Swap File
|
# Enabling the Swap File
|
||||||
|
|
|
@ -24,6 +24,8 @@ fi
|
||||||
|
|
||||||
gradleVersion="8.1.1"
|
gradleVersion="8.1.1"
|
||||||
|
|
||||||
|
shouldBeCarefulWithMaxHeap=0 # This is NOT a cmd-arg.
|
||||||
|
|
||||||
if [[ justRun -eq 0 ]]; then
|
if [[ justRun -eq 0 ]]; then
|
||||||
|
|
||||||
if [[ avoidReInstallingPublicationsRetriever -eq 1 ]]; then
|
if [[ avoidReInstallingPublicationsRetriever -eq 1 ]]; then
|
||||||
|
@ -69,12 +71,14 @@ if [[ justRun -eq 0 ]]; then
|
||||||
|
|
||||||
export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH
|
export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH
|
||||||
|
|
||||||
# Update the max-heap-size based on the machine's physical memory.
|
if [[ shouldBeCarefulWithMaxHeap -eq 1 ]]; then
|
||||||
machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB.
|
# Update the max-heap-size based on the machine's physical memory.
|
||||||
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).
|
machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB.
|
||||||
# Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m"
|
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).
|
||||||
echo -e "\n\nThe max-heap-size (-Xmx) will be set to: ${max_heap_size_mb}m\n\n"
|
# Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m"
|
||||||
sed -i "s/'-Xmx[0-9]\+[gm]'/'-Xmx${max_heap_size_mb}m'/g" ./build.gradle
|
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
|
gradle wrapper --gradle-version=${gradleVersion} --distribution-type=bin
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ public class GeneralController {
|
||||||
shouldShutdownWorker = true;
|
shouldShutdownWorker = true;
|
||||||
|
|
||||||
finalMsg += " The worker will shutdown, after finishing current work.";
|
finalMsg += " The worker will shutdown, after finishing current work.";
|
||||||
|
|
||||||
logger.info(initMsg + finalMsg);
|
logger.info(initMsg + finalMsg);
|
||||||
return ResponseEntity.ok().body(finalMsg + "\n");
|
return ResponseEntity.ok().body(finalMsg + "\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue