- Fix scripts to new java 6 conditions
- improve to execute kill when it detects that server didn't stop
This commit is contained in:
parent
4c58c7e1c1
commit
0eaee94caa
|
@ -25,7 +25,7 @@ ADEMPIEREUSER=adempiere
|
||||||
# detected some problems with Hardy Heron ubuntu using the bash source command
|
# detected some problems with Hardy Heron ubuntu using the bash source command
|
||||||
ENVFILE=/home/adempiere/.bashrc
|
ENVFILE=/home/adempiere/.bashrc
|
||||||
# STOPMESSAGE="Halting VM" # Message when using java 5
|
# STOPMESSAGE="Halting VM" # Message when using java 5
|
||||||
STOPMESSAGE="INFO.*\[Server\].*Shutting down the server" # Message when using java 6
|
STOPMESSAGE="INFO.*Server\].*Shutdown complete" # Message when using java 6
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
|
@ -34,143 +34,156 @@ ADEMPIERESTATUS=
|
||||||
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes)
|
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes)
|
||||||
|
|
||||||
getadempierestatus() {
|
getadempierestatus() {
|
||||||
ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR)
|
ADEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $EXECDIR)
|
||||||
echo $ADEMPIERESTATUSSTRING | grep -q $EXECDIR
|
echo $ADEMPIERESTATUSSTRING | grep -q $EXECDIR
|
||||||
ADEMPIERESTATUS=$?
|
ADEMPIERESTATUS=$?
|
||||||
}
|
}
|
||||||
|
|
||||||
start () {
|
start () {
|
||||||
getadempierestatus
|
getadempierestatus
|
||||||
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
||||||
echo "ADempiere is already running"
|
echo "ADempiere is already running"
|
||||||
return 1
|
return 1
|
||||||
fi
|
|
||||||
echo -n "Starting ADempiere ERP: "
|
|
||||||
. $ENVFILE
|
|
||||||
export LOGFILE=$ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_`date +%Y%m%d%H%M%S`.log
|
|
||||||
su $ADEMPIEREUSER -c "mkdir -p $ADEMPIERE_HOME/jboss/server/adempiere/log"
|
|
||||||
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &"
|
|
||||||
RETVAL=$?
|
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
|
||||||
# wait for server to be confirmed as started in logfile
|
|
||||||
STATUSTEST=0
|
|
||||||
ITERATIONS=0
|
|
||||||
while [ $STATUSTEST -eq 0 ] ; do
|
|
||||||
sleep 2
|
|
||||||
tail -n 5 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1
|
|
||||||
echo -n "."
|
|
||||||
ITERATIONS=`expr $ITERATIONS + 1`
|
|
||||||
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
|
||||||
then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if [ $STATUSTEST -eq 0 ]
|
|
||||||
then
|
|
||||||
log_warning_msg "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service"
|
|
||||||
else
|
|
||||||
log_success_msg "Service started"
|
|
||||||
fi
|
fi
|
||||||
|
echo -n "Starting ADempiere ERP: "
|
||||||
|
. $ENVFILE
|
||||||
|
export LOGFILE=$ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_`date +%Y%m%d%H%M%S`.log
|
||||||
|
su $ADEMPIEREUSER -c "mkdir -p $ADEMPIERE_HOME/jboss/server/adempiere/log"
|
||||||
|
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2.sh &> $LOGFILE &"
|
||||||
|
RETVAL=$?
|
||||||
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
|
# wait for server to be confirmed as started in logfile
|
||||||
|
STATUSTEST=0
|
||||||
|
ITERATIONS=0
|
||||||
|
while [ $STATUSTEST -eq 0 ] ; do
|
||||||
|
sleep 2
|
||||||
|
tail -n 9 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1
|
||||||
|
echo -n "."
|
||||||
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ $STATUSTEST -eq 0 ]
|
||||||
|
then
|
||||||
|
log_warning_msg "Service hasn't started within the timeout allowed, please review file $LOGFILE to see the status of the service"
|
||||||
|
else
|
||||||
|
log_success_msg "Service started"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
log_failure_msg "Service not started"
|
||||||
echo
|
echo
|
||||||
else
|
fi
|
||||||
log_failure_msg "Service not started"
|
return $RETVAL
|
||||||
echo
|
|
||||||
fi
|
|
||||||
return $RETVAL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop () {
|
stop () {
|
||||||
getadempierestatus
|
getadempierestatus
|
||||||
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
||||||
echo "ADempiere is already stopped"
|
echo "ADempiere is already stopped"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
echo -n "Stopping ADempiere ERP: "
|
echo -n "Stopping ADempiere ERP: "
|
||||||
. $ENVFILE
|
. $ENVFILE
|
||||||
export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1`
|
# export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1`
|
||||||
|
export LASTLOG=$ADEMPIERE_HOME/jboss/server/adempiere/log/server.log
|
||||||
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
# wait for server to be confirmed as halted in logfile
|
# wait for server to be confirmed as halted in logfile
|
||||||
STATUSTEST=0
|
STATUSTEST=0
|
||||||
ITERATIONS=0
|
ITERATIONS=0
|
||||||
while [ $STATUSTEST -eq 0 ] ; do
|
while [ $STATUSTEST -eq 0 ] ; do
|
||||||
sleep 2
|
sleep 2
|
||||||
tail -n 9 $LASTLOG | grep -q "$STOPMESSAGE" && STATUSTEST=1
|
tail -n 9 $LASTLOG | grep -q "$STOPMESSAGE" && STATUSTEST=1
|
||||||
echo -n "."
|
echo -n "."
|
||||||
ITERATIONS=`expr $ITERATIONS + 1`
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ $STATUSTEST -eq 0 ]
|
if [ $STATUSTEST -eq 0 ]
|
||||||
then
|
then
|
||||||
log_warning_msg "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
|
log_warning_msg "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
|
||||||
else
|
log_warning_msg "Trying direct kill with signal -15"
|
||||||
|
# Adempiere didn't finish - try direct kill with signal 15, then signal 9
|
||||||
|
kill -15 `ps ax | grep -v grep | grep $EXECDIR | sed -e 's/^ *//g' | cut -f 1 -d " "`
|
||||||
|
sleep 5
|
||||||
|
getadempierestatus
|
||||||
|
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
||||||
|
log_success_msg "Service stopped with kill -15"
|
||||||
|
else
|
||||||
|
echo "Trying direct kill with signal -9"
|
||||||
|
kill -9 `ps ax | grep -v grep | grep $EXECDIR | sed -e 's/^ *//g' | cut -f 1 -d " "`
|
||||||
|
sleep 5
|
||||||
|
getadempierestatus
|
||||||
|
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
||||||
|
log_success_msg "Service stopped with kill -9"
|
||||||
|
else
|
||||||
|
log_warning_msg "Service hasn't stopped"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
log_success_msg "Service stopped"
|
log_success_msg "Service stopped"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
log_failure_msg "Service not stopped"
|
log_failure_msg "Service not stopped"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
return $RETVAL
|
return $RETVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
restart () {
|
restart () {
|
||||||
stop
|
stop
|
||||||
sleep 1
|
sleep 1
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
condrestart () {
|
condrestart () {
|
||||||
getadempierestatus
|
getadempierestatus
|
||||||
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
||||||
restart
|
restart
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
rhstatus () {
|
rhstatus () {
|
||||||
getadempierestatus
|
getadempierestatus
|
||||||
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
if [ $ADEMPIERESTATUS -eq 0 ] ; then
|
||||||
echo
|
echo
|
||||||
echo "ADempiere is running:"
|
echo "ADempiere is running:"
|
||||||
ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
|
ps ax | grep -v grep | grep $EXECDIR | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
echo "ADempiere is stopped"
|
echo "ADempiere is stopped"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
stop)
|
||||||
stop)
|
stop
|
||||||
stop
|
;;
|
||||||
;;
|
reload)
|
||||||
|
restart
|
||||||
reload)
|
;;
|
||||||
restart
|
restart)
|
||||||
;;
|
restart
|
||||||
|
;;
|
||||||
restart)
|
condrestart)
|
||||||
restart
|
condrestart
|
||||||
;;
|
;;
|
||||||
|
status)
|
||||||
condrestart)
|
rhstatus
|
||||||
condrestart
|
;;
|
||||||
;;
|
*)
|
||||||
|
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
|
||||||
status)
|
exit 1
|
||||||
rhstatus
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
|
|
||||||
exit 1
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -21,7 +21,7 @@ EXECDIR=/home/adempiere/Adempiere
|
||||||
ENVFILE=/home/adempiere/.bash_profile
|
ENVFILE=/home/adempiere/.bash_profile
|
||||||
ADEMPIEREUSER=adempiere
|
ADEMPIEREUSER=adempiere
|
||||||
# STOPMESSAGE="Halting VM" # Message when using java 5
|
# STOPMESSAGE="Halting VM" # Message when using java 5
|
||||||
STOPMESSAGE="INFO.*\[Server\].*Shutting down the server" # Message when using java 6
|
STOPMESSAGE="INFO.*Server\].*Shutdown complete" # Message when using java 6
|
||||||
|
|
||||||
. /etc/rc.d/init.d/functions
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
|
@ -53,12 +53,12 @@ start () {
|
||||||
ITERATIONS=0
|
ITERATIONS=0
|
||||||
while [ $STATUSTEST -eq 0 ] ; do
|
while [ $STATUSTEST -eq 0 ] ; do
|
||||||
sleep 2
|
sleep 2
|
||||||
tail -n 5 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1
|
tail -n 9 $LOGFILE | grep -q 'INFO.*\[Server\].*Started in' && STATUSTEST=1
|
||||||
echo -n "."
|
echo -n "."
|
||||||
ITERATIONS=`expr $ITERATIONS + 1`
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ $STATUSTEST -eq 0 ]
|
if [ $STATUSTEST -eq 0 ]
|
||||||
|
@ -84,7 +84,8 @@ stop () {
|
||||||
fi
|
fi
|
||||||
echo -n "Stopping ADempiere ERP: "
|
echo -n "Stopping ADempiere ERP: "
|
||||||
source $ENVFILE
|
source $ENVFILE
|
||||||
export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1`
|
# export LASTLOG=`ls -t $ADEMPIERE_HOME/jboss/server/adempiere/log/adempiere_??????????????.log | head -1`
|
||||||
|
export LASTLOG=$ADEMPIERE_HOME/jboss/server/adempiere/log/server.log
|
||||||
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
su $ADEMPIEREUSER -c "cd $EXECDIR/utils;$EXECDIR/utils/RUN_Server2Stop.sh &> /dev/null &"
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
if [ $RETVAL -eq 0 ] ; then
|
if [ $RETVAL -eq 0 ] ; then
|
||||||
|
@ -98,13 +99,30 @@ stop () {
|
||||||
ITERATIONS=`expr $ITERATIONS + 1`
|
ITERATIONS=`expr $ITERATIONS + 1`
|
||||||
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
if [ $ITERATIONS -gt $MAXITERATIONS ]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ $STATUSTEST -eq 0 ]
|
if [ $STATUSTEST -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
|
echo "Service hasn't stopped within the timeout allowed, please review file $LASTLOG to see the status of the service"
|
||||||
echo_warning
|
echo "Trying direct kill with signal -15"
|
||||||
|
# Adempiere didn't finish - try direct kill with signal 15, then signal 9
|
||||||
|
kill -15 `ps ax | grep -v grep | grep $EXECDIR | sed -e 's/^ *//g' | cut -f 1 -d " "`
|
||||||
|
sleep 5
|
||||||
|
getadempierestatus
|
||||||
|
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
||||||
|
echo_success
|
||||||
|
else
|
||||||
|
echo "Trying direct kill with signal -9"
|
||||||
|
kill -9 `ps ax | grep -v grep | grep $EXECDIR | sed -e 's/^ *//g' | cut -f 1 -d " "`
|
||||||
|
sleep 5
|
||||||
|
getadempierestatus
|
||||||
|
if [ $ADEMPIERESTATUS -ne 0 ] ; then
|
||||||
|
echo_success
|
||||||
|
else
|
||||||
|
echo_warning
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo_success
|
echo_success
|
||||||
fi
|
fi
|
||||||
|
@ -118,7 +136,7 @@ stop () {
|
||||||
|
|
||||||
restart () {
|
restart () {
|
||||||
stop
|
stop
|
||||||
sleep 1
|
sleep 2
|
||||||
start
|
start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,10 +162,10 @@ rhstatus () {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
reload)
|
reload)
|
||||||
restart
|
restart
|
||||||
;;
|
;;
|
||||||
|
@ -161,8 +179,8 @@ case "$1" in
|
||||||
rhstatus
|
rhstatus
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
|
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}"
|
||||||
exit 1
|
exit 1
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue