From d527b6279fd787c3eb4a48864882f0cedbb0f6b3 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Mon, 18 Jun 2018 11:36:40 +0200 Subject: [PATCH] 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 --- .../unix/DebianInstaller/etc/init.d/idempiere | 12 ++++++------ .../utils.unix/unix/idempiere_Debian.sh | 12 ++++++------ .../utils.unix/unix/idempiere_RedHat.sh | 18 +++++++++--------- .../utils.unix/unix/idempiere_Suse.sh | 17 +++++++---------- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/org.adempiere.server-feature/utils.unix/unix/DebianInstaller/etc/init.d/idempiere b/org.adempiere.server-feature/utils.unix/unix/DebianInstaller/etc/init.d/idempiere index 565bfd0b41..d79728fc31 100755 --- a/org.adempiere.server-feature/utils.unix/unix/DebianInstaller/etc/init.d/idempiere +++ b/org.adempiere.server-feature/utils.unix/unix/DebianInstaller/etc/init.d/idempiere @@ -39,7 +39,7 @@ esac # adjust these variables to your environment IDEMPIERE_USER=idempiere 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` SU=su @@ -533,8 +533,8 @@ Enter postgres password:" } getidempierestatus() { - IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep ${IDEMPIERE_HOME}) - echo $IDEMPIERESTATUSSTRING | grep -q ${IDEMPIERE_HOME} + IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep) + echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application IDEMPIERESTATUS=$? } @@ -626,14 +626,14 @@ stop () { log_success_msg "Service stopped with OSGi shutdown" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then log_success_msg "Service stopped with kill -15" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then @@ -664,7 +664,7 @@ dostatus () { if [ $IDEMPIERESTATUS -eq 0 ] ; then echo 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 else echo "iDempiere is stopped" diff --git a/org.adempiere.server-feature/utils.unix/unix/idempiere_Debian.sh b/org.adempiere.server-feature/utils.unix/unix/idempiere_Debian.sh index b516ac781f..760b307d6d 100644 --- a/org.adempiere.server-feature/utils.unix/unix/idempiere_Debian.sh +++ b/org.adempiere.server-feature/utils.unix/unix/idempiere_Debian.sh @@ -32,8 +32,8 @@ IDEMPIERESTATUS= MAXITERATIONS=60 getidempierestatus() { - IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) - echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME + IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep) + echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application IDEMPIERESTATUS=$? } @@ -96,14 +96,14 @@ stop () { log_success_msg "Service stopped with OSGi shutdown" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then log_success_msg "Service stopped with kill -15" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then @@ -118,7 +118,7 @@ stop () { restart () { stop - sleep 1 + sleep 2 start } @@ -134,7 +134,7 @@ status () { if [ $IDEMPIERESTATUS -eq 0 ] ; then echo 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 else echo "iDempiere is stopped" diff --git a/org.adempiere.server-feature/utils.unix/unix/idempiere_RedHat.sh b/org.adempiere.server-feature/utils.unix/unix/idempiere_RedHat.sh index ae6d4637a0..4e96fd83f7 100644 --- a/org.adempiere.server-feature/utils.unix/unix/idempiere_RedHat.sh +++ b/org.adempiere.server-feature/utils.unix/unix/idempiere_RedHat.sh @@ -25,11 +25,11 @@ IDEMPIEREUSER=idempiere RETVAL=0 IDEMPIERESTATUS= -MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes) +MAXITERATIONS=60 # 2 seconds every iteration, max wait 2 minutes getidempierestatus() { - IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) - echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME + IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep) + echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application IDEMPIERESTATUS=$? } @@ -78,7 +78,7 @@ start () { stop () { getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then - echo "idempiere is already stopped" + echo "iDempiere is already stopped" return 1 fi echo -n "Stopping iDempiere ERP: " @@ -92,14 +92,14 @@ stop () { echo_success else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then echo_success else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then @@ -130,11 +130,11 @@ status () { getidempierestatus if [ $IDEMPIERESTATUS -eq 0 ] ; then echo - echo "idempiere is running:" - ps ax | grep -v grep | grep $IDEMPIERE_HOME | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' + echo "iDempiere is running:" + ps ax | grep org.adempiere.server.application | grep -v grep | sed 's/^[[:space:]]*\([[:digit:]]*\).*:[[:digit:]][[:digit:]][[:space:]]\(.*\)/\1 \2/' echo else - echo "idempiere is stopped" + echo "iDempiere is stopped" fi } diff --git a/org.adempiere.server-feature/utils.unix/unix/idempiere_Suse.sh b/org.adempiere.server-feature/utils.unix/unix/idempiere_Suse.sh index 063dca949b..a999dc31d4 100644 --- a/org.adempiere.server-feature/utils.unix/unix/idempiere_Suse.sh +++ b/org.adempiere.server-feature/utils.unix/unix/idempiere_Suse.sh @@ -57,8 +57,8 @@ IDEMPIERESTATUS= MAXITERATIONS=60 getidempierestatus() { - IDEMPIERESTATUSSTRING=$(ps ax | grep -v grep | grep $IDEMPIERE_HOME) - echo $IDEMPIERESTATUSSTRING | grep -q $IDEMPIERE_HOME + IDEMPIERESTATUSSTRING=$(ps ax | grep java | grep org.adempiere.server.application | grep -v grep) + echo $IDEMPIERESTATUSSTRING | grep -q org.adempiere.server.application IDEMPIERESTATUS=$? } @@ -123,14 +123,14 @@ stop () { echo "Service stopped with OSGi shutdown" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then echo "Service stopped with kill -15" else 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 getidempierestatus if [ $IDEMPIERESTATUS -ne 0 ] ; then @@ -146,7 +146,7 @@ stop () { restart () { stop - sleep 1 + sleep 2 start rc_status } @@ -166,7 +166,7 @@ status () { if [ $IDEMPIERESTATUS -eq 0 ] ; then echo 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 else echo "iDempiere is stopped" @@ -182,9 +182,6 @@ case "$1" in stop) stop ;; - reload) - restart - ;; restart) restart ;; @@ -195,7 +192,7 @@ case "$1" in status ;; *) - echo $"Usage: $0 {start|stop|reload|restart|condrestart|status}" + echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac