File gearman_proxy.init of Package mod_gearman

#!/bin/sh
#          
# /etc/init.d/gearman_proxy
#   and its symbolic link
# /usr/sbin/rcgearman_proxy
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
# 
# Note: This template uses functions rc_XXX defined in /etc/rc.status on
# UnitedLinux/SUSE/Novell based Linux distributions. If you want to base your
# script on this template and ensure that it works on non UL based LSB 
# compliant Linux distributions, you either have to provide the rc.status
# functions from UL or change the script to work without them.
# See skeleton.compat for a template that works with other distros as well.
#
### BEGIN INIT INFO
# Provides:          mod_gearman_proxy gearman_proxy
# Required-Start:    $network $remote_fs 
# Should-Start:      $time gearmand
# Required-Stop:     $network $remote_fs
# Should-Stop:       gearmand
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: Start/Stop the mod_gearman proxy daemon
# Description:       Start mod_gearman_proxy to proxy Gearman Jobs 
#	from one jobserver to another jobserver.
### END INIT INFO
#

PROXY=/usr/share/mod_gearman/gearman_proxy.pl
PIDFILE=/var/run/mod_gearman_proxy.pid
LOGFILE=/var/log/mod_gearman/proxy.log
CONFIGFILE=/etc/mod_gearman/gearman_proxy.cfg
NAME=gearman_proxy

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x "$PROXY" || { echo "$PROXY not installed";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 5; fi; }

test -r "$CONFIGFILE" || { echo "$CONFIGFILE not existing or readable";
        if [ "$1" = "stop" ]; then exit 0;
        else exit 6; fi; }

# Shell functions sourced from /etc/rc.status:
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
    start)
        echo -n "Starting $NAME "
		test -d $(dirname "$PIDFILE") || mkdir -p $(dirname "$PIDFILE")
        /sbin/startproc "$PROXY" --log="$LOGFILE" --pid="$PIDFILE" --config="$CONFIGFILE"
		rc_status -v
	;;
	stop)
		echo -n "Stopping $NAME "
		/sbin/killproc -TERM $PROXY
		rc_status -v
	;;
    try-restart|condrestart)
        if test "$1" = "condrestart"; then
                echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
        fi
        $0 status
        if test $? = 0; then
                $0 restart
        else
                rc_reset 
        fi
        rc_status
    ;;
    restart)
        $0 stop
        $0 start
        rc_status
    ;;
    force-reload)
        $0 try-restart
        rc_status
	;;
	reload)
        rc_failed 3
        rc_status -v
	;;
    status)
        echo -n "Checking for $NAME "
		/sbin/checkproc "$PROXY"
		rc_status -v
    ;;
    probe)
		test "$CONFIGFILE" -nt "$PIDFILE" && echo reload
	;;
    *)
        echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe}"
        exit 1
        ;;
esac
rc_exit
openSUSE Build Service is sponsored by