Skip to content

Instantly share code, notes, and snippets.

@kristi
Created September 4, 2011 20:39
Show Gist options
  • Save kristi/1193476 to your computer and use it in GitHub Desktop.
Save kristi/1193476 to your computer and use it in GitHub Desktop.
auto-restart passenger
#!/bin/bash
# Restarts passenger after any *.py *.html or *.po files are saved
#
# Requires inotify-tools
appDir="/home/user/site.com/appname"
siteDir=$(dirname "$appdir")
# Make sure app directory exists
if [[ ! -e "$appDir" ]] ; then
echo "'$appDir' does not exist"
fi
# Create tmp dir if necessary
if [[ ! -e "$siteDir/tmp" ]] ; then
mkdir "$siteDir/tmp"
fi
# Check files
while true; do
inotifywait -e close_write $(find "$dir" -name "*.py" -o -name "*.html" -o -name "*.po")
echo "$(date) Restarting..."
touch "$siteDir/tmp/restart.txt"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment