1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-08-24 17:49:28 +03:00

bug #354: kills any running daemon if OpenNebula fails to start

This commit is contained in:
Ruben S. Montero
2011-01-28 23:59:35 +01:00
parent a821bf8455
commit f1bff01ca5

View File

@ -40,6 +40,9 @@ else
LOCK_FILE=$ONE_LOCATION/var/.lock LOCK_FILE=$ONE_LOCATION/var/.lock
fi fi
#------------------------------------------------------------------------------
# Function that checks for running daemons and gets PORT from conf
#------------------------------------------------------------------------------
setup() setup()
{ {
PORT=$(sed -n '/^[ \t]*PORT/s/^.*PORT\s*=\s*\([0-9]\+\)\s*.*$/\1/p' \ PORT=$(sed -n '/^[ \t]*PORT/s/^.*PORT\s*=\s*\([0-9]\+\)\s*.*$/\1/p' \
@ -72,6 +75,25 @@ setup()
fi fi
} }
#------------------------------------------------------------------------------
# Function that stops the daemons
#------------------------------------------------------------------------------
stop()
{
if [ -f $ONE_PID ]; then
kill `cat $ONE_PID` > /dev/null 2>&1
rm -f $ONE_PID > /dev/null 2>&1
fi
if [ -f $ONE_SCHEDPID ]; then
kill `cat $ONE_SCHEDPID` > /dev/null 2>&1
rm -f $ONE_SCHEDPID > /dev/null 2>&1
fi
}
#------------------------------------------------------------------------------
# Function that starts the daemons
#------------------------------------------------------------------------------
start() start()
{ {
if [ ! -x "$ONED" ]; then if [ ! -x "$ONED" ]; then
@ -95,7 +117,6 @@ start()
fi fi
fi fi
# Backup oned.log # Backup oned.log
if [ "$BACKUP" = "true" ];then if [ "$BACKUP" = "true" ];then
[ -f "$ONE_LOG" ] && cp $ONE_LOG{,.$(date '+%Y%m%d%H%M')} [ -f "$ONE_LOG" ] && cp $ONE_LOG{,.$(date '+%Y%m%d%H%M')}
@ -157,40 +178,13 @@ start()
fi fi
if [ "$STARTED" == "false" ]; then if [ "$STARTED" == "false" ]; then
stop
exit -1 exit -1
fi fi
} }
# #------------------------------------------------------------------------------
# Function that stops the daemon/service #------------------------------------------------------------------------------
#
stop()
{
if [ ! -f $ONE_PID ]; then
echo "Couldn't find oned process pid."
exit 1
fi
if [ ! -f $ONE_SCHEDPID ]; then
echo "Couldn't find scheduler process pid."
exit 1
fi
# Kill the one daemon
kill `cat $ONE_PID` > /dev/null 2>&1
# Kill the scheduler
kill `cat $ONE_SCHEDPID` > /dev/null 2>&1
# Remove pid files
rm -f $ONE_PID > /dev/null 2>&1
rm -f $ONE_SCHEDPID > /dev/null 2>&1
echo "oned and scheduler stopped"
}
if [ "$1" = "-b" ]; then if [ "$1" = "-b" ]; then
BACKUP=true BACKUP=true
@ -204,6 +198,7 @@ case "$1" in
;; ;;
stop) stop)
stop stop
echo "oned and scheduler stopped"
;; ;;
*) *)
echo "Usage: one [-b] {start|stop}" >&2 echo "Usage: one [-b] {start|stop}" >&2
@ -212,4 +207,3 @@ case "$1" in
exit 3 exit 3
;; ;;
esac esac