awips2/rpms/awips2.qpid/0.18/SOURCES/qpidd
Steve Harris cbf859daf6 14.1.1-4 baseline
Former-commit-id: cb3b53f205 [formerly 82dec19b6a] [formerly bd95bb6a4e] [formerly cb3b53f205 [formerly 82dec19b6a] [formerly bd95bb6a4e] [formerly 99e3707c5b [formerly bd95bb6a4e [formerly 0cda967cc9da9d2a08a0197db23d48c65f03be81]]]]
Former-commit-id: 99e3707c5b
Former-commit-id: 2039d101ef [formerly b60635cd70] [formerly 2d757fef6618aded3efb26a4e6771f03101fe824 [formerly 7590a56e0e]]
Former-commit-id: 973d527ee973fdb4fc285ca2d02f0a43a03bb0fa [formerly 98ae84da42]
Former-commit-id: da4589ec2b
2013-10-28 10:55:16 -04:00

159 lines
3.3 KiB
Bash

#!/bin/bash
#
# qpidd This shell script takes care of starting and stopping
# the AWIPS qpid instance.
#
# chkconfig: - 99 10
# description: Qpid messaging broker used by the AWIPS 2 instance
# processname: qpid-server
# config: /awips2/qpid/etc/config.xml
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
RETVAL=0
prog="qpid-wrapper"
# Who to run QPID as, usually "awips". (NOT "root")
QPIDUSER=awips
# Todays date in format of YYYYMMDD.
TODAY=`/bin/date +%Y%m%d`
QPID_HOME=/awips2/qpid
wrapper_process="org.rzo.yajsw.app.WrapperJVMMain"
_wrapper_jar=${QPID_HOME}/bin/yajsw/wrapper.jar
function getQPID_psCount()
{
psCount_qpid=`ps -ef | grep ${wrapper_process} | grep QPID_HOME="${QPID_HOME}" | grep -c "PNAME=QPBRKR "`
}
function getQPID_pid()
{
pid_qpid=`ps -e -o pid,args | grep ${wrapper_process} | grep QPID_HOME="${QPID_HOME}" | grep "PNAME=QPBRKR " | grep -e "^ *\([0-9]\+\)" -o`
}
function getWrapper_psCount()
{
psCount_wrapper=`ps -ef | grep "${_wrapper_jar} -c" | grep -c wrapper.conf`
}
function getWrapper_pid()
{
pid_wrapper=`ps -e -o pid,args | grep "${_wrapper_jar} -c" | grep wrapper.conf | grep -e "^ *\([0-9]\+\)" -o`
}
start() {
getQPID_psCount
if [ ${psCount_qpid} -eq 1 ]; then
echo "WARNING: QPID already running, not starting another instance"
return 1
fi
DAEMON="/bin/bash ${QPID_HOME}/bin/${prog}"
QPIDSTARTLOG=${QPID_HOME}/log/start-qpid-$TODAY.log
su $QPIDUSER -c "$DAEMON" >> $QPIDSTARTLOG 2>&1 &
sleep 5
checkStatus
}
stop() {
# determine if qpid is running, first.
getQPID_psCount
if [ ${psCount_qpid} -ne 1 ]; then
echo "WARNING: Qpid is not running, no shutdown attempted!"
return 1
fi
# get the qpid pid
getQPID_pid
# determine if the qpid wrapper is running.
getWrapper_psCount
if [ ${psCount_wrapper} -eq 1 ]; then
# get the wrapper pid
getWrapper_pid
# stop the wrapper
kill ${pid_wrapper}
else
# stop qpid
kill ${pid_qpid}
fi
# wait for and verify that qpid has stopped running
savepid=${pid_qpid}
while [ "X${pid_qpid}" != "X" ]; do
sleep 1
getQPID_psCount
if [ ${psCount_qpid} -eq 1 ]; then
pid_qpid=${savepid}
else
pid_qpid=""
fi
done
}
checkStatus() {
getQPID_psCount
if [ ${psCount_qpid} -eq 1 ]; then
getQPID_pid
echo "QPID is running (PID ${pid_qpid})"
else
echo "QPID is not running"
fi
}
# Verify root user
checkUser() {
REQUIREDUSER="root"
CURUSER=`whoami`
if [ "$CURUSER" != "$REQUIREDUSER" ]; then
echo "Insufficient privileges: must run script as $REQUIREDUSER"
exit 1
fi
}
# See how we were called.
case $1 in
start)
checkUser
echo "Starting QPID"
start
RETVAL=$?
;;
stop)
checkUser
echo "Stopping QPID"
stop
RETVAL=$?
;;
restart)
checkUser
echo "Stopping QPID"
stop
echo "Starting QPID"
start
RETVAL=$?
;;
status)
checkStatus
RETVAL=$?
;;
*)
# Print help
echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac
exit $RETVAL