#!/bin/bash

# Shut the site down, for instance by tweaking a .htaccess file to display
# a 'please wait' notice, or stopping a node server

if [ ! -f "app.js" ]; then
  echo "I don't see app.js in the current directory."
  exit 1
fi

# Stop the node app via 'forever'. You'll get a harmless warning if the app
# was not already running. Use `pwd` to make sure we have a full path,
# forever is otherwise easily confused and will stop every server with
# the same filename
forever stop `pwd`/app.js && echo "Site stopped"

# Stop the app without 'forever'. We recommend using 'forever' for node apps,
# but this may be your best bet for non-node apps
#
# if [ -f "data/pid" ]; then
#   kill `cat data/pid`
#   rm data/pid
#   echo "Site stopped"
# else
#   echo "Site was not running"
# fi

