Commit 8e379cb8 authored by Alex Mateescu's avatar Alex Mateescu Committed by alexm

OF-581 Process management improvements

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13330 b35dd754-fafc-0310-a699-88a17e54d16e
parent 329b3cb8
...@@ -22,10 +22,17 @@ PATH="/sbin:/bin:/usr/bin:/usr/sbin" ...@@ -22,10 +22,17 @@ PATH="/sbin:/bin:/usr/bin:/usr/sbin"
RETVAL=0 RETVAL=0
# Check that we are root ... so non-root users stop here. # Check that we are root ... so non-root users stop here.
[ "`id -u`" = 0 ] || exit 1 if [ "`id -u`" != 0 ]; then
echo $0 must be run as root
exit 1
fi
# Get config. # Get config.
[ -f "/etc/sysconfig/openfire" ] && . /etc/sysconfig/openfire [ -f "/etc/sysconfig/openfire" ] && . /etc/sysconfig/openfire
if [ -f "/etc/init.d/functions" ]; then
FUNCTIONS_FOUND=true
. /etc/init.d/functions
fi
# If openfire user is not set in sysconfig, set to daemon. # If openfire user is not set in sysconfig, set to daemon.
[ -z "$OPENFIRE_USER" ] && OPENFIRE_USER="daemon" [ -z "$OPENFIRE_USER" ] && OPENFIRE_USER="daemon"
...@@ -107,10 +114,9 @@ start() { ...@@ -107,10 +114,9 @@ start() {
OLD_PWD=`pwd` OLD_PWD=`pwd`
cd $OPENFIRE_LOGDIR cd $OPENFIRE_LOGDIR
# Check if the server is already running. We look only for the pid file PID=$(findPID)
pid=`cat $OPENFIRE_PIDFILE 2>&1` if [ -n "$PID" ]; then
if [ "$?" = "0" ]; then echo "Openfire is already running."
echo "Openfire is already running. Remove $OPENFIRE_PIDFILE if you know this to be untrue."
RETVAL=1 RETVAL=1
return return
fi fi
...@@ -121,11 +127,6 @@ start() { ...@@ -121,11 +127,6 @@ start() {
rm -f nohup.out rm -f nohup.out
su -s /bin/sh -c "nohup $OPENFIRE_RUN_CMD > $OPENFIRE_LOGDIR/nohup.out 2>&1 &" $OPENFIRE_USER su -s /bin/sh -c "nohup $OPENFIRE_RUN_CMD > $OPENFIRE_LOGDIR/nohup.out 2>&1 &" $OPENFIRE_USER
RETVAL=$? RETVAL=$?
PID=`ps ax --width=1000 | grep openfire | grep startup.jar | awk '{print $1}'`
if [ $RETVAL -eq 0 -a ! -z "$PID" -a ! -z "$OPENFIRE_PIDFILE" ]; then
echo $PID > $OPENFIRE_PIDFILE
fi
echo echo
...@@ -139,11 +140,23 @@ stop() { ...@@ -139,11 +140,23 @@ stop() {
# Stop daemons. # Stop daemons.
echo -n "Shutting down openfire: " echo -n "Shutting down openfire: "
[ -f "$OPENFIRE_PIDFILE" ] && kill `cat $OPENFIRE_PIDFILE` PID=$(findPID)
if [ -n "$PID" ]; then
if [ -n "$FUNCTIONS_FOUND" ]; then
echo $PID > $OPENFIRE_PIDFILE
# delay copied from restart
killproc -p $OPENFIRE_PIDFILE -d 10
rm -f $OPENFIRE_PIDFILE
else
kill $PID
fi
else
echo "Openfire is not running."
fi
RETVAL=$? RETVAL=$?
echo echo
[ $RETVAL -eq 0 -a -f "$OPENFIRE_PIDFILE" ] && rm -f $OPENFIRE_PIDFILE
[ $RETVAL -eq 0 -a -f "/var/lock/subsys/openfire" ] && rm -f /var/lock/subsys/openfire [ $RETVAL -eq 0 -a -f "/var/lock/subsys/openfire" ] && rm -f /var/lock/subsys/openfire
} }
...@@ -159,22 +172,19 @@ condrestart() { ...@@ -159,22 +172,19 @@ condrestart() {
} }
status() { status() {
pid=`cat $OPENFIRE_PIDFILE 2>&1` PID=$(findPID)
if [ "$?" = "1" ]; then if [ -n "$PID" ]; then
echo "openfire is not running"
RETVAL=3
else
ps -p $pid > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo "openfire is running" echo "openfire is running"
RETVAL=0 RETVAL=0
else else
echo "openfire is not running" echo "openfire is not running"
RETVAL=1 RETVAL=1
fi fi
fi
} }
findPID() {
echo `ps ax --width=1000 | grep openfire | grep startup.jar | awk '{print $1}'`
}
# Handle how we were called. # Handle how we were called.
case "$1" in case "$1" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment