Discourse won't install because I have 960MB of ram and not 1GB

Over at meta discourse, Kloxified asks:

Discourse sends the error and then just cancels the installation how do I make it install?

ram_discoruse

This topic was prematurely closed in my view so I will reply here.

First all of:

discourse~# cd /var/discourse
discourse:/var/discourse# cd launcher
discourse:/var/discourse# grep "1GB RAM" *

discourse-setup:    echo "WARNING: Discourse requires 1GB RAM to run. This system does not appear"

If we look at discourse-setup we can easily see what is going on:

##
## OS X available memory
##
check_osx_memory() {
  echo `free -m | awk '/Mem:/ {print $2}'`
}

##
## Linux available memory
##
check_linux_memory() {
  ## some VMs report just under 1GB of RAM, so
  ## make an exception and allow those with more
  ## than 989MB
  mem=`free -m --si | awk ' /Mem:/ {print $2}'`
  if [ "$mem" -ge 990 -a "$mem" -lt 1000 ]; then
    echo 1
  else
    echo `free -g --si | awk ' /Mem:/  {print $2} '`
  fi
}

##
## Do we have enough memory and disk space for Discourse?
##
check_disk_and_memory() {

  os_type=$(check_OS)
  avail_mem=0
  if [ "$os_type" == "Darwin" ]; then
    avail_mem=$(check_osx_memory)
  else
    avail_mem=$(check_linux_memory)
  fi

  if [ "$avail_mem" -lt 1 ]; then
    echo "WARNING: Discourse requires 1GB RAM to run. This system does not appear"
    echo "to have sufficient memory."
    echo
    echo "Your site may not work properly, or future upgrades of Discourse may not"
    echo "complete successfully."
    exit 1
  fi

  if [ "$avail_mem" -le 2 ]; then
    total_swap=`free -g --si | awk ' /Swap:/  {print $2} '`

    if [ "$total_swap" -lt 2 ]; then
      echo "WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM"
      echo "or less. This system does not appear to have sufficient swap space."
      echo
      echo "Without sufficient swap space, your site may not work properly, and future"
      echo "upgrades of Discourse may not complete successfully."
      echo
      echo "Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created."
      sleep 5

      ##
  ##
      ## derived from https://meta.discourse.org/t/13880
      ##
      install -o root -g root -m 0600 /dev/null /swapfile
      fallocate -l 2G /swapfile
      mkswap /swapfile
      swapon /swapfile
      echo "/swapfile       swap    swap    auto      0       0" | tee -a /etc/fstab
      sysctl -w vm.swappiness=10
      echo 'vm.swappiness = 10' > /etc/sysctl.d/30-discourse-swap.conf

      total_swap=`free -g --si | awk ' /Swap:/ {print $2} '`
      if [ "$total_swap" -lt 2 ]; then
        echo "Failed to create swap: are you root? Are you running on real hardware, or a fully virtualized server?"
        exit 1
      fi

    fi
  fi

The script calls this function here:

##
## Check requirements before creating a copy of a config file we won't edit
##
check_root
check_and_install_docker
check_disk_and_memory

My advice to Kloxified is to just comment out this validation routine as follows:

##
## Check requirements before creating a copy of a config file we won't edit
##
check_root
check_and_install_docker
## commented out this validator -> check_disk_and_memory

Why?

The reason is that Kloxified said his system has 960 MB of RAM, and discourse requires 1 GB or the setup routine fails.

Doing the math: 960/1024 is 94% of the hard requirement for 1GB RAM

It is best for Kloxified, to try his new Discourse install on 960MB of RAM and later, when his community grows, s/he can upgrade if he wants to.

Or, s/he can upgrade before installing if he chooses to do so; but if there is a reason he does not want to upgrade first, simply commenting out this validator will help him proceed smoothly.

Reference:

1 Like