Detected that when the server crashes because of Out Of Memory the init.d scripts are not able to terminate it properly / fix to look for the server using org.adempiere.server.application instead of the IDEMPIERE_HOME

This commit is contained in:
Carlos Ruiz 2018-06-18 11:36:40 +02:00
parent 9f9249869a
commit d527b6279f
4 changed files with 28 additions and 31 deletions

View File

@ -39,7 +39,7 @@ esac
# adjust these variables to your environment # adjust these variables to your environment
IDEMPIERE_USER=idempiere IDEMPIERE_USER=idempiere
IDEMPIERE_HOME=/opt/idempiere-server IDEMPIERE_HOME=/opt/idempiere-server
JAVA_HOME=`ls -r /usr/lib/jvm/java-[678]-openjdk*/bin/javac /usr/lib/jvm/java-[8]-oracle*/bin/javac | head -1` JAVA_HOME=`ls -r /usr/lib/jvm/java-[6789]-openjdk*/bin/javac /usr/lib/jvm/java-[89]-oracle*/bin/javac | head -1`
JAVA_HOME=`dirname $JAVA_HOME` JAVA_HOME=`dirname $JAVA_HOME`
JAVA_HOME=`dirname $JAVA_HOME` JAVA_HOME=`dirname $JAVA_HOME`
SU=su SU=su
@ -533,8 +533,8 @@ Enter postgres password:"
} }
getidempierestatus() { getidempierestatus() {
IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep ${IDEMPIERE_HOME}) IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep)
echo $IDEMPIERESTATUSSTRING | grep -q ${IDEMPIERE_HOME} echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application
IDEMPIERESTATUS=$? IDEMPIERESTATUS=$?
} }
@ -626,14 +626,14 @@ stop () {
log_success_msg "Service stopped with OSGi shutdown" log_success_msg "Service stopped with OSGi shutdown"
else else
log_warning_msg "Trying direct kill with signal -15" log_warning_msg "Trying direct kill with signal -15"
kill -15 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -15 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
log_success_msg "Service stopped with kill -15" log_success_msg "Service stopped with kill -15"
else else
log_warning_msg "Trying direct kill with signal -9" log_warning_msg "Trying direct kill with signal -9"
kill -9 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -9 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
@ -664,7 +664,7 @@ dostatus () {
if [ $IDEMPIERESTATUS -eq 0 ] ; then if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo echo
echo "iDempiere is running:" echo "iDempiere is running:"
ps ax | grep -v grep | grep ${IDEMPIERE_HOME} | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' ps ax | grep org.adempiere.server.application | grep -v grep | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo echo
else else
echo "iDempiere is stopped" echo "iDempiere is stopped"

View File

@ -32,8 +32,8 @@ IDEMPIERESTATUS=
MAXITERATIONS=60 MAXITERATIONS=60
getidempierestatus() { getidempierestatus() {
IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep)
echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application
IDEMPIERESTATUS=$? IDEMPIERESTATUS=$?
} }
@ -96,14 +96,14 @@ stop () {
log_success_msg "Service stopped with OSGi shutdown" log_success_msg "Service stopped with OSGi shutdown"
else else
log_warning_msg "Trying direct kill with signal -15" log_warning_msg "Trying direct kill with signal -15"
kill -15 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -15 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
log_success_msg "Service stopped with kill -15" log_success_msg "Service stopped with kill -15"
else else
log_warning_msg "Trying direct kill with signal -9" log_warning_msg "Trying direct kill with signal -9"
kill -9 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -9 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
@ -118,7 +118,7 @@ stop () {
restart () { restart () {
stop stop
sleep 1 sleep 2
start start
} }
@ -134,7 +134,7 @@ status () {
if [ $IDEMPIERESTATUS -eq 0 ] ; then if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo echo
echo "iDempiere is running:" echo "iDempiere is running:"
ps ax | grep -v grep | grep $IDEMPIERE_HOME | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' ps ax | grep org.adempiere.server.application | grep -v grep | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo echo
else else
echo "iDempiere is stopped" echo "iDempiere is stopped"

View File

@ -25,11 +25,11 @@ IDEMPIEREUSER=idempiere
RETVAL=0 RETVAL=0
IDEMPIERESTATUS= IDEMPIERESTATUS=
MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes) MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes
getidempierestatus() { getidempierestatus() {
IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep)
echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application
IDEMPIERESTATUS=$? IDEMPIERESTATUS=$?
} }
@ -78,7 +78,7 @@ start () {
stop () { stop () {
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo "idempiere is already stopped" echo "iDempiere is already stopped"
return 1 return 1
fi fi
echo -n "Stopping iDempiere ERP: " echo -n "Stopping iDempiere ERP: "
@ -92,14 +92,14 @@ stop () {
echo_success echo_success
else else
echo "Trying direct kill with signal -15" echo "Trying direct kill with signal -15"
kill -15 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -15 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo_success echo_success
else else
echo "Trying direct kill with signal -9" echo "Trying direct kill with signal -9"
kill -9 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -9 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
@ -130,11 +130,11 @@ status () {
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -eq 0 ] ; then if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo echo
echo "idempiere is running:" echo "iDempiere is running:"
ps ax | grep -v grep | grep $IDEMPIERE_HOME | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' ps ax | grep org.adempiere.server.application | grep -v grep | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo echo
else else
echo "idempiere is stopped" echo "iDempiere is stopped"
fi fi
} }

View File

@ -57,8 +57,8 @@ IDEMPIERESTATUS=
MAXITERATIONS=60 MAXITERATIONS=60
getidempierestatus() { getidempierestatus() {
IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep)
echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application
IDEMPIERESTATUS=$? IDEMPIERESTATUS=$?
} }
@ -123,14 +123,14 @@ stop () {
echo "Service stopped with OSGi shutdown" echo "Service stopped with OSGi shutdown"
else else
echo "Trying direct kill with signal -15" echo "Trying direct kill with signal -15"
kill -15 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -15 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
echo "Service stopped with kill -15" echo "Service stopped with kill -15"
else else
echo "Trying direct kill with signal -9" echo "Trying direct kill with signal -9"
kill -9 -`ps ax o pgid,command | grep -v grep | grep $IDEMPIERE_HOME | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u` kill -9 -`ps ax o pgid,command | grep org.adempiere.server.application | grep -v grep | sed -e 's/^ *//g' | cut -f 1 -d " " | sort -u`
sleep 5 sleep 5
getidempierestatus getidempierestatus
if [ $IDEMPIERESTATUS -ne 0 ] ; then if [ $IDEMPIERESTATUS -ne 0 ] ; then
@ -146,7 +146,7 @@ stop () {
restart () { restart () {
stop stop
sleep 1 sleep 2
start start
rc_status rc_status
} }
@ -166,7 +166,7 @@ status () {
if [ $IDEMPIERESTATUS -eq 0 ] ; then if [ $IDEMPIERESTATUS -eq 0 ] ; then
echo echo
echo "iDempiere is running:" echo "iDempiere is running:"
ps ax | grep -v grep | grep $IDEMPIERE_HOME | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' ps ax | grep org.adempiere.server.application | grep -v grep | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/'
echo echo
else else
echo "iDempiere is stopped" echo "iDempiere is stopped"
@ -182,9 +182,6 @@ case "$1" in
stop) stop)
stop stop
;; ;;
reload)
restart
;;
restart) restart)
restart restart
;; ;;
@ -195,7 +192,7 @@ case "$1" in
status status
;; ;;
*) *)
echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" echo $"Usage: $0 {start|stop|restart|condrestart|status}"
exit 1 exit 1
esac esac