From 452c82886447fe47e10437d13c247c798137ba32 Mon Sep 17 00:00:00 2001 From: Ghaith Olabi Date: Mon, 29 Jan 2024 20:29:04 +0100 Subject: [PATCH 1/2] feat(docker): add monolithic memory checks --- templates/docker-monolithic/setup.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/templates/docker-monolithic/setup.sh b/templates/docker-monolithic/setup.sh index 31cdcd6..8596708 100755 --- a/templates/docker-monolithic/setup.sh +++ b/templates/docker-monolithic/setup.sh @@ -224,6 +224,24 @@ configure() { bash <(curl -LsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/create_volumes.sh) } +check_memory() { + if [[ "$os_type" == "windows" ]] || [[ "$os_type" == "macos" ]]; then + return + fi + + # Get total memory (RAM + Swap) in kilobytes + total_memory=$(awk '/MemTotal/ {mem=$2} /SwapTotal/ {swap=$2} END {print mem+swap}' /proc/meminfo) + + # 4GB + required_memory=$((4*1024*1024)) + + if (( total_memory < required_memory )); then + echo "Error: Your system has less than 4GB of total memory (RAM + Swap)." + echo "Please upgrade your system memory to at least 4GB." + exit 1 + fi +} + cat << "EOF" ____ _ ____ _ / ___| _ _ _ __ _ __ ___ _ __| |_| _ \ __ _| | @@ -235,6 +253,7 @@ EOF echo identify_os +check_memory configure_windows check_docker check_docker_compose From 084e9061d330ea7d6575e2af5015b5f64b7f04e6 Mon Sep 17 00:00:00 2001 From: Kieran Date: Tue, 30 Jan 2024 14:21:02 +0000 Subject: [PATCH 2/2] Update setup.sh --- templates/docker-monolithic/setup.sh | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/templates/docker-monolithic/setup.sh b/templates/docker-monolithic/setup.sh index 8596708..bc11d52 100755 --- a/templates/docker-monolithic/setup.sh +++ b/templates/docker-monolithic/setup.sh @@ -225,21 +225,33 @@ configure() { } check_memory() { - if [[ "$os_type" == "windows" ]] || [[ "$os_type" == "macos" ]]; then - return - fi + if ! [ -f /proc/meminfo ]; then + return + fi - # Get total memory (RAM + Swap) in kilobytes - total_memory=$(awk '/MemTotal/ {mem=$2} /SwapTotal/ {swap=$2} END {print mem+swap}' /proc/meminfo) + # Get total memory (RAM + Swap) in kilobytes + total_memory=$(awk '/MemTotal/ {mem=$2} /SwapTotal/ {swap=$2} END {print mem+swap}' /proc/meminfo) - # 4GB - required_memory=$((4*1024*1024)) + # 4GB (approx) + required_memory=$((4*1000*1000)) - if (( total_memory < required_memory )); then - echo "Error: Your system has less than 4GB of total memory (RAM + Swap)." - echo "Please upgrade your system memory to at least 4GB." - exit 1 - fi + if (( total_memory < required_memory )); then + echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####" + echo " !! WARNING !! " + echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####" + echo "" + echo "The system has less than 4GB of total memory (RAM + Swap)," + echo "detected ${total_memory}KB. The system may crash if launched with" + echo "insufficient memory." + echo + echo "Greater than ${required_memory}KB is recommended." + echo + echo "Press CTRL+C to exit and add more RAM/Swap. Continuing in 15s..." + echo + echo "##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####" + echo + sleep 15 + fi } cat << "EOF"