Source

CherryPy / cherrypy / restsrv / restctl.sh

#!/bin/sh
#
# Control script for the restsrv daemon

ERROR=0
PYTHON=python
RESTD=restd.py
PIDFILE=/var/log/restsrv/restd.pid

# Determine if restsrv is already running.
RUNNING=0
if [ -f $PIDFILE ]; then
    PID=`cat $PIDFILE`
    if [ "x$PID" != "x" ]; then
        if kill -0 $PID 2>/dev/null ; then
            # a process using PID is running
            if ps -p $PID -o args | grep restsrv > /dev/null 2>&1; then
                # that process is restsrv itself
                RUNNING=1
            fi
        fi
    fi
    if ["$RUNNING" = "0"]; then
        STATUS="restsrv (stale pid file removed) not running"
        rm -f $PIDFILE
    fi
else
    STATUS="restsrv (no pid) not running"
fi

ARGS=""
COMMAND=""
for ARG in $@; do
    case $ARG in
    start|stop|restart|graceful|status)
        COMMAND=$ARG
        ;;
    *)
        ARGS="$ARGS $ARG"
    esac
    fi
done

case $COMMAND in
start)
    echo "Starting restd"
    $RESTD $ARGS
    ERROR=$?
    ;;
stop)
    echo "Stopping restd"
    kill -TERM `cat $PIDFILE`
    ERROR=$?
    ;;
restart)
    echo "Restarting restd"
    kill -HUP `cat $PIDFILE`
    ;;
graceful)
    echo "Gracefully restarting restd"
    kill -USR1 `cat $PIDFILE`
    ;;
status)
    echo $STATUS
    ;;
*)
    $RESTD $ARGS
    ERROR=$?
esac

exit $ERROR
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.