Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Non-safe init.d script
#!/bin/sh
NAME='example.com'
USER='example_user'
PROJDIRPRE="/sites/"
PYTHON="/sites/envs/project/bin/python"
SAFE_NAME=`echo "$NAME" | sed 's/\./_/g'`
PROJDIR="$PROJDIRPRE/$SAFE_NAME"
PIDFILE="/tmp/$SAFE_NAME.pid"
SOCKET="/tmp/$SAFE_NAME.sock"
case "$1" in
restart)
$0 stop $NAME
$0 start $NAME
;;
start)
echo "Starting $NAME server..."
if [ -f $PIDFILE ]; then
$0 stop $NAME
fi
su -l $USER -c "$PYTHON $PROJDIR/manage.py runfcgi method=prefork maxspare=30 socket=$SOCKET pidfile=$PIDFILE"
chmod a+w $SOCKET
;;
stop)
PID=`cat $PIDFILE`
kill $PID
while [ -x /proc/${PID} ]
do
echo "Waiting for $NAME to shutdown ..."
sleep 1
done
echo "$NAME stopped"
unlink $PIDFILE;
unlink $SOCKET;
;;
*)
echo "Usage: $THIS {start|stop|restart}" >&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.