-
-check_resources() {
- # Memory
- resources="ok"
- avail_mem="$(LANG=C free -m | grep '^Mem:' | awk '{print $2}')"
- 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"
- elif [ "$avail_mem" -lt 1800 ]; then
- total_swap="$(LANG=C free -m | grep ^Swap: | awk '{print $2}')"
- if [ "$total_swap" -lt 1000 ]; then
- resources="insufficient"
- 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"
- fi
- fi
-
- # Disk space
- free_disk="$(df /var | tail -n 1 | awk '{print $4}')"
- if [ "$free_disk" -lt 5000 ]; then
- 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."
- echo
- echo "Run \`apt-get autoremove && apt-get autoclean\` to clean up unused packages and \`./launcher cleanup\` to remove stale Docker containers."
- 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
-}
-
-check_ports() {
- local valid=$(netstat -tln | awk '{print $4}' | grep ":${1}\$")
-
- if [ -n "$valid" ]; then
- echo "Launcher has detected that port ${1} is in use."
- echo
- echo "If you are trying to run Discourse simultaneously with another web server like Apache or nginx, you will need to bind to a different port."
- echo "See https://meta.discourse.org/t/17247 for help."
- echo "To continue anyway, re-run Launcher with --skip-prereqs"
- exit 1
- fi
-}
-
-if [ "$opt" != "--skip-prereqs" ] ; then
- prereqs
-fi
-
-if [ "$opt" == "--docker-args" ] ; then
- user_args=$4
-else
- user_args=""