Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(docker): add monolithic memory checks #175

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions templates/docker-monolithic/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,36 @@ configure() {
bash <(curl -LsS https://raw.githubusercontent.com/supportpal/helpdesk-install/"${ref}"/templates/docker-monolithic/create_volumes.sh)
}

check_memory() {
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)

# 4GB (approx)
required_memory=$((4*1000*1000))

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"
____ _ ____ _
/ ___| _ _ _ __ _ __ ___ _ __| |_| _ \ __ _| |
Expand All @@ -235,6 +265,7 @@ EOF

echo
identify_os
check_memory
configure_windows
check_docker
check_docker_compose
Expand Down