Skip to content

Commit

Permalink
Clean up and fix redhat init script.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Gaffney committed Oct 1, 2008
1 parent 4b28ba0 commit eda6919
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 47 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
== 0.9.9
* remove dependency on SyslogLogger so that starling works on windows.
* fix config file loading so relative paths are expanded properly <jacob@jacobatzen.dk>
* clean up redhat init.d script <gaffneyc@gmail.com>

== 0.9.8
* add fix to enable relative paths <david@motorator.com>
Expand Down
97 changes: 50 additions & 47 deletions etc/starling.redhat
Original file line number Diff line number Diff line change
@@ -1,63 +1,66 @@
#!/bin/bash
#
# Make sure the /var/run/starling, /var/log/starling and /var/spool/starling
# all exist and are owned by starling:starling
#
# starling This shell script takes care of starting and stopping
# the starling server
# chkconfig: 345 98 98
# description: The starling queue server
# processname: starling
# pidfile: /var/run/starling/starling.pid
# logfile: /var/log/starling/starling.log

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
[ -f /etc/sysconfig/network ] && . /etc/sysconfig/network

DUSER=starling
DGROUP=starling
LOGFILE=/var/log/starling/starling.log
SPOOLDIR=/var/spool/starling
PORT=22122
LISTEN=0.0.0.0
PIDFILE=/var/run/starling/starling.pid

#determine where the 'pidof' executable is located
if [ -e /bin/pidof ]; then
PIDOF="/bin/pidof"
elif [ -e /sbin/pidof ]; then
PIDOF="/sbin/pidof"
elif [ -e /usr/local/bin/pidof ]; then
PIDOF="/usr/local/bin/pidof"
elif [ -e /bin/pgrep ]; then
PIDOF="/bin/pgrep"
elif [ -e /usr/bin/pgrep ]; then
PIDOF="/usr/bin/pgrep"
elif [ -e /usr/local/bin/pgrep ]; then
PIDOF="/usr/local/bin/pgrep"
else
echo "Could not find pidof or pgrep"
fi

PROGDIR="/usr/bin"
PROGNAME="starling"
OPTIONS="-u nobody -g nobody -L /var/log/starling.log -q /var/spool/starling"
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=starling
INSTALL_DIR=/usr/local/bin
DAEMON=$INSTALL_DIR/$NAME
OPTS="-h $LISTEN -p $PORT -d -q $SPOOLDIR -P $PIDFILE -L $LOGFILE -u $DUSER -g $DGROUP"

start() {
pid=`$PIDOF $PROGNAME`
if [ "$pid" != "" ]; then
echo "$PROGDIR$PROGNAME already running: $pid"
else
echo "Starting $PROGDIR$PROGNAME"
cd $PROGDIR
nohup $PROGDIR$PROGNAME $OPTIONS &
fi
echo -n $"Starting starling: "

daemon --pidfile=$PIDFILE $DAEMON $OPTS
echo
}

stop() {
pid=`$PIDOF $PROGNAME`
if [ "$pid" != "" ]; then
echo "Stopping $PROGDIR$PROGNAME: $pid"
kill $pid
else
echo "$PROGDIR$PROGNAME not running"
fi
echo -n $"Stopping starling: "

killproc -p $PIDFILE starling
echo
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;

start)
start
;;
stop)
stop
;;
restart)
stop
sleep 3
start
;;
status)
status -p $PIDFILE starling
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
exit 1
esac

0 comments on commit eda6919

Please sign in to comment.