Issue #2231 Make edex startup more configurable

* Allow for skipping the RPM check
* Allow for using system java in wrapper instead of hard-coded /awips2/java
* Allow for configuring wrapper process actions with system variables
  e.g. RESTART vs. SHUTDOWN on crash

Change-Id: Icaa3b3e388013a8106db6e29fd999aa5824c72bc

Former-commit-id: 3bb1b03cb7 [formerly e056592ba9] [formerly 3bb1b03cb7 [formerly e056592ba9] [formerly 9515d45e9d [formerly 7834360e8c56ac74b29a585eeda8c0387067250b]]]
Former-commit-id: 9515d45e9d
Former-commit-id: 37ce990b54 [formerly b9dda179a0]
Former-commit-id: eec23b6971
This commit is contained in:
Everett Kladstrup 2013-07-25 10:41:45 -05:00
parent a229db50f0
commit 33693f1903
7 changed files with 63 additions and 46 deletions

View file

@ -20,42 +20,44 @@
## ##
# edex startup script # edex startup script
# Verify that awips2-python and awips2-java are installed. if [ -z "${SKIP_RPM_CHECK}" ]; then
rpm -q awips2-python > /dev/null 2>&1 # Verify that awips2-python and awips2-java are installed.
RC=$? rpm -q awips2-python > /dev/null 2>&1
if [ ${RC} -ne 0 ]; then RC=$?
echo "ERROR: awips2-python Must Be Installed." if [ ${RC} -ne 0 ]; then
echo "Unable To Continue ... Terminating." echo "ERROR: awips2-python Must Be Installed."
exit 1 echo "Unable To Continue ... Terminating."
fi exit 1
fi
rpm -q awips2-java > /dev/null 2>&1 rpm -q awips2-java > /dev/null 2>&1
RC=$? RC=$?
if [ ${RC} -ne 0 ]; then if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-java Must Be Installed." echo "ERROR: awips2-java Must Be Installed."
echo "Unable To Continue ... Terminating." echo "Unable To Continue ... Terminating."
exit 1 exit 1
fi fi
rpm -q awips2-psql > /dev/null 2>&1 rpm -q awips2-psql > /dev/null 2>&1
RC=$? RC=$?
if [ ${RC} -ne 0 ]; then if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-psql Must Be Installed." echo "ERROR: awips2-psql Must Be Installed."
echo "Unable To Continue ... Terminating." echo "Unable To Continue ... Terminating."
exit 1 exit 1
fi
fi fi
# Find the locations of awips2-python and awips2-java.
PYTHON_INSTALL="/awips2/python"
JAVA_INSTALL="/awips2/java"
PSQL_INSTALL="/awips2/psql"
path_to_script=`readlink -f $0` path_to_script=`readlink -f $0`
dir=$(dirname $path_to_script) dir=$(dirname $path_to_script)
export EDEX_HOME=$(dirname $dir) export EDEX_HOME=$(dirname $dir)
awips_home=$(dirname $EDEX_HOME) awips_home=$(dirname $EDEX_HOME)
# Find the locations of awips2-python and awips2-java.
PYTHON_INSTALL="$awips_home/python"
JAVA_INSTALL="$awips_home/java"
PSQL_INSTALL="$awips_home/psql"
# Source The File With The Localization Information # Source The File With The Localization Information
source ${dir}/setup.env source ${dir}/setup.env
@ -80,8 +82,7 @@ export PATH=$PATH:$awips_home/GFESuite/bin:$awips_home/GFESuite/ServiceBackup/sc
export PATH=$PATH:$PROJECT/bin export PATH=$PATH:$PROJECT/bin
export JAVA_HOME="${JAVA_INSTALL}" export JAVA_HOME="${JAVA_INSTALL}"
export LD_LIBRARY_PATH=$EDEX_HOME/lib/native/linux32/awips1:${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:${PSQL_INSTALL}/lib:$PROJECT/sharedLib export LD_LIBRARY_PATH=$EDEX_HOME/lib/lib_illusion:$EDEX_HOME/lib/native/linux32/awips1:${JAVA_INSTALL}/lib:${PYTHON_INSTALL}/lib:${PSQL_INSTALL}/lib:$PROJECT/sharedLib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/awips2/edex/lib/lib_illusion:$LD_LIBRARY_PATH
export LD_PRELOAD="libpython.so" export LD_PRELOAD="libpython.so"
export FXA_DATA=$EDEX_HOME/data/fxa export FXA_DATA=$EDEX_HOME/data/fxa

View file

@ -23,7 +23,7 @@
wrapper.debug=false wrapper.debug=false
set.default.EDEX_HOME=../.. set.default.EDEX_HOME=../..
wrapper.working.dir=/awips2/edex/bin wrapper.working.dir=${EDEX_HOME}/bin
# required due to java bug: # required due to java bug:
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388188 # http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388188
# not sure if the yajsw developers have any intention of # not sure if the yajsw developers have any intention of
@ -34,11 +34,14 @@ wrapper.fork_hack=true
wrapper.console.pipestreams=true wrapper.console.pipestreams=true
# Java Application # Java Application
wrapper.java.command=/awips2/java/bin/java wrapper.java.command=${EDEX_HOME}/../java/bin/java
# necessary for etc/init.d/edex_camel # necessary for etc/init.d/edex_camel
wrapper.pidfile=${EDEX_HOME}/bin/${EDEX_RUN_MODE}.pid wrapper.pidfile=${EDEX_HOME}/bin/${EDEX_RUN_MODE}.pid
# use system java instead of awips2 java
wrapper.app.env.use.system.java=${WRAPPER_USE_SYSTEM_JAVA}
# Java Classpath (include wrapper.jar) Add class path elements as # Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1 # needed starting from 1
wrapper.java.classpath.1=${EDEX_HOME}/bin/yajsw/wrapper.jar wrapper.java.classpath.1=${EDEX_HOME}/bin/yajsw/wrapper.jar
@ -167,13 +170,13 @@ wrapper.java.monitor.heap.threshold.percent = 90
wrapper.java.monitor.deadlock = true wrapper.java.monitor.deadlock = true
# application will be restarted and a warning message will be logged # application will be restarted and a warning message will be logged
wrapper.filter.action.deadlock.restart=RESTART wrapper.filter.action.deadlock.restart=${WRAPPER_DEADLOCK_ACTION}
# restart the application if it crashes # restart the application if it crashes
wrapper.on_exit.default=RESTART wrapper.on_exit.default=${WRAPPER_ON_EXIT_ACTION}
# restart the application if it runs out of memory # restart the application if it runs out of memory
wrapper.trigger.1=java.lang.OutOfMemoryError wrapper.trigger.1=java.lang.OutOfMemoryError
wrapper.trigger.action=RESTART wrapper.trigger.action=${WRAPPER_TRIGGER_ACTION}
#******************************************************************** #********************************************************************
# Wrapper Logging Properties # Wrapper Logging Properties

View file

@ -42,3 +42,8 @@ export SERIALIZE_STREAM_MAX_SIZE_MB=6
export LOG_CONF=logback.xml export LOG_CONF=logback.xml
export MGMT_PORT=9600 export MGMT_PORT=9600
export WRAPPER_DEADLOCK_ACTION=RESTART
export WRAPPER_ON_EXIT_ACTION=RESTART
export WRAPPER_TRIGGER_ACTION=RESTART
export WRAPPER_USE_SYSTEM_JAVA=false

View file

@ -8,6 +8,7 @@ import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang.BooleanUtils;
import org.rzo.yajsw.boot.WrapperLoader; import org.rzo.yajsw.boot.WrapperLoader;
import org.rzo.yajsw.io.CyclicBufferFileInputStream; import org.rzo.yajsw.io.CyclicBufferFileInputStream;
import org.rzo.yajsw.io.CyclicBufferFilePrintStream; import org.rzo.yajsw.io.CyclicBufferFilePrintStream;
@ -260,20 +261,27 @@ public class BSDProcess extends PosixProcess
private String getCurrentJava() private String getCurrentJava()
{ {
int myPid = OperatingSystem.instance().processManagerInstance().currentProcessId(); Boolean system_java = BooleanUtils.toBoolean(getEnvironmentAsMap().get(
Process myProcess = OperatingSystem.instance().processManagerInstance().getProcess(myPid); "use.system.java"));
String cmd = myProcess.getCommand();
String jvm = null;
if (cmd.startsWith("\""))
jvm = cmd.substring(0, cmd.indexOf("\" ") + 1);
else
jvm = cmd.substring(0, cmd.indexOf(" "));
/* String java = "/awips2/java/bin/java";
* bkowal
* Always return the AWIPS II Java. if (system_java) {
*/ int myPid = OperatingSystem.instance().processManagerInstance()
return "/awips2/java/bin/java"; .currentProcessId();
Process myProcess = OperatingSystem.instance()
.processManagerInstance().getProcess(myPid);
String cmd = myProcess.getCommand();
String jvm = null;
if (cmd.startsWith("\""))
jvm = cmd.substring(0, cmd.indexOf("\" ") + 1);
else
jvm = cmd.substring(0, cmd.indexOf(" "));
java = jvm;
}
return java;
} }
public String getCommandInternal() public String getCommandInternal()