AppHa_healthCheck
#!/bin/bash
LOOP_FLG=true
while $LOOP_FLG
do
ret=`sh ./healthCheck.sh`
status=$?
if [ $status = 1 ]
then
LOOP_FLG=false
fi
sleep 50
done
exit 0
#pxsctl
#!/bin/sh
usage()
{
echo >&2 ""
echo >&2 " Usage: $0 {start | stop} "
echo >&2 ""
}
# Main
if [ $# != 1 ]; then
usage
exit 1
fi
EXEC_UNIX_USER=wlsadmin
username=`id -u -n`
if [ ! $username = $EXEC_UNIX_USER ]; then
echo >&2 ""
echo >&2 " Executed it by user $EXEC_UNIX_USER."
echo >&2 " aborting..."
echo >&2 ""
exit 1
fi
CHECK_INTERVAL_SEC=10
CHECK_RETRY_TIMES=2
AUTORUN=/shell/autoRun
LOG_FILE=/autoRun/log/log.log
get_log_line()
{
if [ -s $LOG_FILE ]; then
wc -l $LOG_FILE | awk 'BEGIN {}
{
len = length($0);
if ( len > 3 ) {
printf "LOG_FILE_LINES=%s ; export LOG_FILE_LINES\n", $1;
}
}' >> tmptmptmp_$$
. ./tmptmptmp_$$
rm tmptmptmp_$$
else
LOG_FILE_LINES=0 ; export LOG_FILE_LINES
fi
}
start_check()
{
sleep 3
LOG_LINES_CHECK=$LOG_FILE_LINES
get_log_line
if [ $LOG_LINES_CHECK -gt $LOG_FILE_LINES ]
then
LOG_FILE_LINES=0
else
LOG_FILE_LINES=$LOG_LINES_CHECK
fi
###### Check if AUTORUN has exactly started.
CHECK_CMD="tail -n +${LOG_FILE_LINES} ${LOG_FILE} | grep \"started normally\""
count=$CHECK_RETRY_TIMES
while [ $count -gt 0 ]
do
sleep $CHECK_INTERVAL_SEC
eval $CHECK_CMD > /dev/null 2>&1
if [ "$?" -eq 0 ]; then
break
fi
echo $count
count=`expr $count - 1`
done
###### "$count==0" means AUTORUN starting-up failed.
if [ $count -eq 0 ]; then
echo "Starting AUTORUN failed."
exit 1
fi
########
/bin/echo
/bin/echo "AUTORUN has started!"
}
case $1 in
'start')
get_log_line
/usr/bin/nohup ${AUTORUN}Start.sh > /dev/null 2>&1 &
;;
'stop')
${AUTORUN}End.sh
;;
*)
usage
exit 1
;;
esac
case $1 in
'start')
start_check
;;
esac
exit 0