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: 9515d45e9d [formerly e056592ba9 [formerly 7834360e8c56ac74b29a585eeda8c0387067250b]]
Former-commit-id: e056592ba9
Former-commit-id: 3bb1b03cb7
This commit is contained in:
Everett Kladstrup 2013-07-25 10:41:45 -05:00
parent a25f442ddc
commit 2c518b816d
7 changed files with 63 additions and 46 deletions

View file

@ -20,42 +20,44 @@
##
# edex startup script
# Verify that awips2-python and awips2-java are installed.
rpm -q awips2-python > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-python Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
if [ -z "${SKIP_RPM_CHECK}" ]; then
# Verify that awips2-python and awips2-java are installed.
rpm -q awips2-python > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-python Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
rpm -q awips2-java > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-java Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
rpm -q awips2-java > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-java Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
fi
rpm -q awips2-psql > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-psql Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
rpm -q awips2-psql > /dev/null 2>&1
RC=$?
if [ ${RC} -ne 0 ]; then
echo "ERROR: awips2-psql Must Be Installed."
echo "Unable To Continue ... Terminating."
exit 1
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`
dir=$(dirname $path_to_script)
export EDEX_HOME=$(dirname $dir)
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 ${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 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=/awips2/edex/lib/lib_illusion:$LD_LIBRARY_PATH
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_PRELOAD="libpython.so"
export FXA_DATA=$EDEX_HOME/data/fxa

View file

@ -23,7 +23,7 @@
wrapper.debug=false
set.default.EDEX_HOME=../..
wrapper.working.dir=/awips2/edex/bin
wrapper.working.dir=${EDEX_HOME}/bin
# required due to java bug:
# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4388188
# not sure if the yajsw developers have any intention of
@ -34,11 +34,14 @@ wrapper.fork_hack=true
wrapper.console.pipestreams=true
# Java Application
wrapper.java.command=/awips2/java/bin/java
wrapper.java.command=${EDEX_HOME}/../java/bin/java
# necessary for etc/init.d/edex_camel
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
# needed starting from 1
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
# 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
wrapper.on_exit.default=RESTART
wrapper.on_exit.default=${WRAPPER_ON_EXIT_ACTION}
# restart the application if it runs out of memory
wrapper.trigger.1=java.lang.OutOfMemoryError
wrapper.trigger.action=RESTART
wrapper.trigger.action=${WRAPPER_TRIGGER_ACTION}
#********************************************************************
# Wrapper Logging Properties

View file

@ -42,3 +42,8 @@ export SERIALIZE_STREAM_MAX_SIZE_MB=6
export LOG_CONF=logback.xml
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.List;
import org.apache.commons.lang.BooleanUtils;
import org.rzo.yajsw.boot.WrapperLoader;
import org.rzo.yajsw.io.CyclicBufferFileInputStream;
import org.rzo.yajsw.io.CyclicBufferFilePrintStream;
@ -260,20 +261,27 @@ public class BSDProcess extends PosixProcess
private String getCurrentJava()
{
int myPid = OperatingSystem.instance().processManagerInstance().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(" "));
Boolean system_java = BooleanUtils.toBoolean(getEnvironmentAsMap().get(
"use.system.java"));
/*
* bkowal
* Always return the AWIPS II Java.
*/
return "/awips2/java/bin/java";
String java = "/awips2/java/bin/java";
if (system_java) {
int myPid = OperatingSystem.instance().processManagerInstance()
.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()