More adjustments to the launcher resource checks
authorMatt Palmer <mpalmer@hezmatt.org>
Tue, 15 Sep 2015 23:56:14 +0000 (09:56 +1000)
committerMatt Palmer <mpalmer@hezmatt.org>
Tue, 15 Sep 2015 23:56:14 +0000 (09:56 +1000)
* Don't *fail* the install, just warn that the user doesn't have enough to
  be comfortable.  We pause the installation to allow the user to go fix
  their system if they want to, but only if they're running interactively.

* Drop the limits for detecting how much RAM a system has, because a VM with
  1GB of RAM doesn't actually *report* that (kernel memory isn't in `free
  -m`).

launcher

index 7475cf62c1cff3a26d041b74ada896a75046bd17..8708d5ea5bb9efd1928e116a7b3e3dc1b053e19d 100755 (executable)
--- a/launcher
+++ b/launcher
@@ -155,30 +155,47 @@ prereqs() {
   # 6. sufficient available resources
   # 6a. Memory
   #
+  resources="ok"
   avail_mem="$(LANG=C free -m | grep '^Mem:' | awk '{print $2}')"
-  if [ "$avail_mem" -lt 1000 ]; then
-    echo "You do not appear to have sufficient memory to run Discourse."
+  if [ "$avail_mem" -lt 900 ]; then
+    resources="insufficient"
+    echo "WARNING: You do not appear to have sufficient memory to run Discourse."
+    echo
+    echo "Your system may not work properly, or future upgrades of Discourse may"
+    echo "not complete successfully."
     echo
     echo "See https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md#create-new-cloud-server"
-    exit 1
-  elif [ "$avail_mem" -lt 2000 ]; then
+  elif [ "$avail_mem" -lt 1800 ]; then
+    resources="insufficient"
     total_swap="$(LANG=C free -m | grep ^Swap: | awk '{print $2}')"
     if [ "$total_swap" -lt 1000 ]; then
-      echo "You must have at least 1GB of swap when running with less than 2GB of RAM."
+      echo "WARNING: You must have at least 1GB of swap when running with less"
+      echo "than 2GB of RAM."
+      echo
+      echo "Your system may not work properly, or future upgrades of Discourse may"
+      echo "not complete successfully."
       echo
       echo "See https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md#set-up-swap-if-needed"
-      exit 1
     fi
   fi
 
   # 6b. Disk space
   free_disk="$(df /var | tail -n 1 | awk '{print $4}')"
   if [ "$free_disk" -lt 5000 ]; then
-    echo "You must have at least 5GB of *free* disk space to install Discourse."
+    resources="insufficient"
+    echo "WARNING: You must have at least 5GB of *free* disk space to run Discourse."
+    echo
+    echo "Insufficient disk space may result in problems running your site, and may"
+    echo "not even allow Discourse installation to complete successfully."
     echo
     echo "Please free up some space, or expand your disk, before continuing."
     exit 1
   fi
+
+  if [ -t 0 ] && [ "$resources" != "ok" ]; then
+    echo
+    read -p "Press ENTER to continue, or Ctrl-C to exit and give your system more resources"
+  fi
 }
 
 if [ "$opt" != "--skip-prereqs" ] ; then