Created
March 29, 2010 12:50
-
-
Save dsc/347808 to your computer and use it in GitHub Desktop.
pylons.sh -- fiddles with pylons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
function halp () { | |
cat <<-HALP | |
pylons -- Starts a Pylons app, creating logs and saving a pidfile. | |
Usage: $( basename $0 ) [INI_FILE] | |
If INI_FILE is not 'development.ini', stdout and stderr are redirected | |
to logs/pylons.log. | |
HALP | |
} | |
function fail () { | |
echo "PREDICTABLE FAILURE. $1" | |
if [ "$2" ]; then halp; fi | |
exit 1 | |
} | |
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then | |
halp; exit 0 | |
fi | |
BASE="$PWD" | |
INI="development.ini" | |
if [[ "$1" != "" ]]; then | |
BASE=$( dirname "$1" ) | |
INI="$1" | |
fi | |
ININAME=$(basename "$INI") | |
PIDFILE="$BASE/paste.pid" | |
if [[ $ININAME == "development.ini" || $ININAME == "dev.ini" ]]; then | |
paster serve --reload $INI | |
else | |
mkdir -p $BASE/logs | |
paster serve --reload $INI >$BASE/logs/pylons.log 2>&1 & | |
sleep 4 | |
ps ux | fgrep -v 'grep|awk' | awk -F '[ \n\t]+' '/paster serve/ { print $2 }' >$PIDFILE 2>/dev/null | |
if [ ! -e $PIDFILE ] || [ -z "$(cat $PIDFILE)" ]; then | |
fail "Unable to find pidfile!" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment