#!/bin/sh DIR="/path/to/project/dir" PID="$DIR/fcgi.pid" SOCKET="/path/to/socket/file" ACTION=$1 NEED_START="yes" PROCESS="" if [ -f $PID ]; then pid=$(cat $PID) if [ -n "$pid" ]; then PROCESS=$(ps -p $pid --no-headers) if [ -n "$PROCESS" ]; then echo "Found active daemon with pid $pid" if [ "$ACTION" == "restart" -o "$ACTION" == "stop" ]; then echo "Killing $pid" kill $pid else NEED_START="no" fi fi fi fi if [ -z "$PROCESS" ]; then echo "No active daemon" fi if [ "$ACTION" == "stop" ]; then NEED_START="no" fi if [ "$NEED_START" == "yes" ]; then cmd="/usr/bin/env python $DIR/manage.py runfcgi method=threaded socket=$SOCKET pidfile=$PID umask=000" echo echo "Starting daemon with command:" echo $cmd echo $cmd fi