Hi (3rd time luck),

On 20 January 2011 09:57, Brett Delle Grazie
<brett.dellegra...@gmail.com> wrote:
> I missed the bit down the end ;)
>
> On 20 January 2011 09:55, Brett Delle Grazie
> <brett.dellegra...@gmail.com> wrote:
>> Hi,
>>
>> On 19 January 2011 12:20, Dejan Muhamedagic <deja...@fastmail.fm> wrote:
>>> Hi,
>>>
>>> On Tue, Jan 18, 2011 at 07:28:55PM +0000, Brett Delle Grazie wrote:
>>>> Hi Dejan,
>>>>
>>>> My changes were in a completely separate SVN repository with other
>>>> client work.  They were rather ad-hoc as I edited things and
>>>> then fixed them after finding problems.  After a while I completely
>>>> forgot about posting back the changes so apologies there.
>>>> I had to rebase my changes using git against the mercurial tip, I'd
>>>> have learnt mercurial but I've only just got my head around git
>>>> and didn't want to make matters worse.
>>>>
>>>> Comments below :)
>>>>
>>>> On 18 January 2011 17:32, Dejan Muhamedagic <deja...@fastmail.fm> wrote:
>>>> > Hi Brett,
>>>> >
>>>> > On Tue, Jan 18, 2011 at 04:08:05PM +0000, Brett Delle Grazie wrote:
>>>> >> Hi,
>>>> >>
>>>> >> Its been a while but here are the patches for using multiple instances
>>>> >> of Tomcat.
>>>> >>
>>>> >> The last one (7) you may or may not wish to use...
>>>> >>
>>>> >> I apologies for having missed this for so long.
>>>> >
>>>> > NP. I appreciate your effort. Comments below.
>>>> >
>>>> >> Enjoy!
>>>> >>
>>>> >> --
>>>> >> Best Regards,
>>>> >>
>>>> >> Brett Delle Grazie
>>>> >
>>>> >> From 1c0a2ef05bfbde930962befd99799d4f6a318231 Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Mon, 17 Jan 2011 22:09:44 +0000
>>>> >> Subject: [PATCH 1/7] Low: tomcat: Use here-documents to simplify 
>>>> >> start/stop operations
>>>> >>
>>>> >> ---
>>>> >>  heartbeat/tomcat |   30 +++++++++++++++---------------
>>>> >>  1 files changed, 15 insertions(+), 15 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 689edc7..671ba82 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -146,14 +146,14 @@ start_tomcat()
>>>> >>               "$CATALINA_HOME/bin/catalina.sh" start $TOMCAT_START_OPTS 
>>>> >> \
>>>> >>                       >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>       else
>>>> >> -             su - -s /bin/sh "$RESOURCE_TOMCAT_USER" \
>>>> >> -                     -c "export JAVA_HOME=${OCF_RESKEY_java_home};\
>>>> >> -                            export JAVA_OPTS=-Dname=${TOMCAT_NAME};\
>>>> >> -                            export 
>>>> >> CATALINA_HOME=${OCF_RESKEY_catalina_home};\
>>>> >> -                            export 
>>>> >> CATALINA_PID=${OCF_RESKEY_catalina_pid};\
>>>> >> -                            export 
>>>> >> CATALINA_OPTS=\"${OCF_RESKEY_catalina_opts}\";\
>>>> >> -                            $CATALINA_HOME/bin/catalina.sh start 
>>>> >> ${OCF_RESKEY_tomcat_start_opts}" \
>>>> >> -                     >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> +             cat<<-END_TOMCAT_START | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> +                     export JAVA_HOME=${OCF_RESKEY_java_home}
>>>> >> +                     export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> +                     export CATALINA_HOME=${OCF_RESKEY_catalina_home}
>>>> >> +                     export CATALINA_PID=${OCF_RESKEY_catalina_pid}
>>>> >> +                     export 
>>>> >> CATALINA_OPTS=\"${OCF_RESKEY_catalina_opts}\"
>>>> >> +                     $CATALINA_HOME/bin/catalina.sh start 
>>>> >> ${OCF_RESKEY_tomcat_start_opts}
>>>> >> +END_TOMCAT_START
>>>> >>       fi
>>>> >>
>>>> >>       while true; do
>>>> >> @@ -181,13 +181,13 @@ stop_tomcat()
>>>> >>                       >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>               eval $tomcat_stop_cmd >> "$TOMCAT_CONSOLE" 2>&1
>>>> >>       else
>>>> >> -             su - -s /bin/sh "$RESOURCE_TOMCAT_USER" \
>>>> >> -                     -c "export JAVA_HOME=${OCF_RESKEY_java_home};\
>>>> >> -                            export JAVA_OPTS=-Dname=${TOMCAT_NAME};\
>>>> >> -                            export 
>>>> >> CATALINA_HOME=${OCF_RESKEY_catalina_home};\
>>>> >> -                            export 
>>>> >> CATALINA_PID=${OCF_RESKEY_catalina_pid};\
>>>> >> -                            $CATALINA_HOME/bin/catalina.sh stop" \
>>>> >> -                     >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> +             cat<<-END_TOMCAT_STOP | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> +                     export JAVA_HOME=${OCF_RESKEY_java_home}
>>>> >> +                     export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> +                     export CATALINA_HOME=${OCF_RESKEY_catalina_home}
>>>> >> +                     export CATALINA_PID=${OCF_RESKEY_catalina_pid}
>>>> >> +                     $CATALINA_HOME/bin/catalina.sh stop
>>>> >> +END_TOMCAT_STOP
>>>> >>       fi
>>>> >>
>>>> >>       lapse_sec=0
>>>> >> --
>>>> >> 1.7.1
>>>> >
>>>> > This seems to be OK.
>>>> >
>>>> >> From 8a7e6c8fd4c5f130e19eadf669550a67473f2fa5 Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 10:42:16 +0000
>>>> >> Subject: [PATCH 2/7] Low: tomcat: Fix to ensure default OCF_RESKEY_xx 
>>>> >> values are observed
>>>> >>
>>>> >> Use the internal name of the OCF_RESKEY_xx variables throughout
>>>> >> ensuring that any defaults set at the beginning are observed.
>>>> >> ---
>>>> >>  heartbeat/tomcat |   16 ++++++++--------
>>>> >>  1 files changed, 8 insertions(+), 8 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 671ba82..9fb948a 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -147,12 +147,12 @@ start_tomcat()
>>>> >>                       >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_START | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> -                     export JAVA_HOME=${OCF_RESKEY_java_home}
>>>> >> +                     export JAVA_HOME=${JAVA_HOME}
>>>> >>                       export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> -                     export CATALINA_HOME=${OCF_RESKEY_catalina_home}
>>>> >> -                     export CATALINA_PID=${OCF_RESKEY_catalina_pid}
>>>> >> -                     export 
>>>> >> CATALINA_OPTS=\"${OCF_RESKEY_catalina_opts}\"
>>>> >> -                     $CATALINA_HOME/bin/catalina.sh start 
>>>> >> ${OCF_RESKEY_tomcat_start_opts}
>>>> >> +                     export CATALINA_HOME=${CATALINA_HOME}
>>>> >> +                     export CATALINA_PID=${CATALINA_PID}
>>>> >> +                     export CATALINA_OPTS="${CATALINA_OPTS}"
>>>> >> +                     $CATALINA_HOME/bin/catalina.sh start 
>>>> >> ${TOMCAT_START_OPTS}
>>>> >>  END_TOMCAT_START
>>>> >>       fi
>>>> >>
>>>> >> @@ -182,10 +182,10 @@ stop_tomcat()
>>>> >>               eval $tomcat_stop_cmd >> "$TOMCAT_CONSOLE" 2>&1
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_STOP | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> -                     export JAVA_HOME=${OCF_RESKEY_java_home}
>>>> >> +                     export JAVA_HOME=${JAVA_HOME}
>>>> >>                       export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> -                     export CATALINA_HOME=${OCF_RESKEY_catalina_home}
>>>> >> -                     export CATALINA_PID=${OCF_RESKEY_catalina_pid}
>>>> >> +                     export CATALINA_HOME=${CATALINA_HOME}
>>>> >> +                     export CATALINA_PID=${CATALINA_PID}
>>>> >>                       $CATALINA_HOME/bin/catalina.sh stop
>>>> >>  END_TOMCAT_STOP
>>>> >>       fi
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > This too. Though the use of variables is making my head spin.
>>>>
>>>> Yes, I know - but these are the same variables (with the same names)
>>>> as used by Tomcat
>>>> when running manually from the command line.
>>>>
>>>> I configure a setenv.sh/setenv.bat file as well but the above
>>>> variables are still needed regardless
>>>
>>> Yes, just wanted to say that it was hard for me to follow.
>>>
>>
>> You and the rest of us too ;)
>> See the other thread for a 'minimalist' resource agent idea.
>>
>>>> >> From 26326c4e3f762efd09b54f9eab3ed79da4192b9c Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 11:03:15 +0000
>>>> >> Subject: [PATCH 3/7] Low: tomcat: Ensure name of tomcat resource is 
>>>> >> only used on start operation and expose JAVA_OPTS variable for use
>>>> >>
>>>> >> A specific string (the 'name') of the tomcat resource agent is added as 
>>>> >> a
>>>> >> define to the JVM. This is used with a grep against the process table in
>>>> >> the monitor operation to determine if the process is still running.
>>>> >> This patch ensures the string is only added to the process on the start
>>>> >> operation.  This patch also exposes the JAVA_OPTS variable for use in
>>>> >> resource definitions.
>>>> >> ---
>>>> >>  heartbeat/tomcat |   19 ++++++++++++++-----
>>>> >>  1 files changed, 14 insertions(+), 5 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 9fb948a..89c20bd 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -29,6 +29,7 @@
>>>> >>  #   OCF_RESKEY_tomcat_user  - A user name to start a resource. Default 
>>>> >> is root
>>>> >>  #   OCF_RESKEY_statusurl - URL for state confirmation. Default is 
>>>> >> http://127.0.0.1:8080
>>>> >>  #   OCF_RESKEY_java_home - Home directory of Java. Default is none
>>>> >> +#   OCF_RESKEY_java_opts - Options to pass to Java JVM for start and 
>>>> >> stop. Default is none
>>>> >>  #   OCF_RESKEY_catalina_home - Home directory of Tomcat. Default is 
>>>> >> none
>>>> >>  #   OCF_RESKEY_catalina_pid  - A PID file name of Tomcat. Default is 
>>>> >> OCF_RESKEY_catalina_home/logs/catalina.pid
>>>> >>  #   OCF_RESKEY_tomcat_start_opts - Start options of Tomcat. Default is 
>>>> >> none.
>>>> >> @@ -148,7 +149,7 @@ start_tomcat()
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_START | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>                       export JAVA_HOME=${JAVA_HOME}
>>>> >> -                     export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> +                     export JAVA_OPTS="${JAVA_OPTS}"
>>>> >>                       export CATALINA_HOME=${CATALINA_HOME}
>>>> >>                       export CATALINA_PID=${CATALINA_PID}
>>>> >>                       export CATALINA_OPTS="${CATALINA_OPTS}"
>>>> >> @@ -183,7 +184,7 @@ stop_tomcat()
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_STOP | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>                       export JAVA_HOME=${JAVA_HOME}
>>>> >> -                     export JAVA_OPTS=-Dname=${TOMCAT_NAME}
>>>> >> +                     export JAVA_OPTS="${JAVA_OPTS}"
>>>> >>                       export CATALINA_HOME=${CATALINA_HOME}
>>>> >>                       export CATALINA_PID=${CATALINA_PID}
>>>> >>                       $CATALINA_HOME/bin/catalina.sh stop
>>>> >> @@ -319,6 +320,14 @@ Home directory of Java.
>>>> >>  <content type="string" default="" />
>>>> >>  </parameter>
>>>> >>
>>>> >> +<parameter name="java_opts" unique="0">
>>>> >> +<longdesc lang="en">
>>>> >> +Java JVM options used on start and stop.
>>>> >> +</longdesc>
>>>> >> +<shortdesc>Java options parsed to JVM, used on start and 
>>>> >> stop.</shortdesc>
>>>> >> +<content type="string" default="" />
>>>> >> +</parameter>
>>>> >> +
>>>> >>  <parameter name="catalina_home" unique="1" required="1">
>>>> >>  <longdesc lang="en">
>>>> >>  Home directory of Tomcat.
>>>> >> @@ -400,15 +409,15 @@ 
>>>> >> RESOURCE_TOMCAT_USER="${OCF_RESKEY_tomcat_user-RUNASIS}"
>>>> >>  RESOURCE_STATUSURL="${OCF_RESKEY_statusurl-http://127.0.0.1:8080}";
>>>> >>
>>>> >>  JAVA_HOME="${OCF_RESKEY_java_home}"
>>>> >> -JAVA_OPTS="-Dname=$TOMCAT_NAME"
>>>> >> -SEARCH_STR="\\""${JAVA_OPTS}"
>>>> >> +JAVA_OPTS="${OCF_RESKEY_java_opts}"
>>>> >>  CATALINA_HOME="${OCF_RESKEY_catalina_home}"
>>>> >>  CATALINA_PID="${OCF_RESKEY_catalina_pid-$CATALINA_HOME/logs/catalina.pid}"
>>>> >>
>>>> >>  TOMCAT_START_OPTS="${OCF_RESKEY_tomcat_start_opts}"
>>>> >> -CATALINA_OPTS="${OCF_RESKEY_catalina_opts}"
>>>> >> +CATALINA_OPTS="-Dname=$TOMCAT_NAME ${OCF_RESKEY_catalina_opts}"
>>>> >>  CATALINA_ROTATE_LOG="${OCF_RESKEY_catalina_rotate_log-NO}"
>>>> >>  CATALINA_ROTATETIME="${OCF_RESKEY_catalina_rotatetime-86400}"
>>>> >> +SEARCH_STR="\\""${CATALINA_OPTS}"
>>>> >>
>>>> >>  export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_PID CATALINA_OPTS
>>>> >>
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > OK. The point is that -Dname=$TOMCAT_NAME moved to
>>>> > CATALINA_OPTS, right?
>>>>
>>>> Yes. CATALINA_OPTS is only used on start and that's the only time we
>>>> want the -Dname=$TOMCAT_NAME to appear
>>>> in the process list.
>>>
>>> OK.
>>>
>>>> >> From b01f09a8033d6a04130fc7e49d7f48844fa72b40 Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 14:16:08 +0000
>>>> >> Subject: [PATCH 4/7] Low: tomcat: remove eval of empty variable - does 
>>>> >> nothing.
>>>> >>
>>>> >> Looks like a left-over from a possible 'execute this on stop' hook.
>>>> >> The variable is not used anywhere else in the file, therefore removing 
>>>> >> it.
>>>> >> ---
>>>> >>  heartbeat/tomcat |    1 -
>>>> >>  1 files changed, 0 insertions(+), 1 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 89c20bd..723e6d8 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -180,7 +180,6 @@ stop_tomcat()
>>>> >>       if [ "$RESOURCE_TOMCAT_USER" = RUNASIS ]; then
>>>> >>               "$CATALINA_HOME/bin/catalina.sh" stop \
>>>> >>                       >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> -             eval $tomcat_stop_cmd >> "$TOMCAT_CONSOLE" 2>&1
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_STOP | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>                       export JAVA_HOME=${JAVA_HOME}
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > Good catch. It's been there from the beginning.
>>>> >
>>>> >> From b140750fd2de4992e7d3959c68a4194f07594d6b Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 14:24:06 +0000
>>>> >> Subject: [PATCH 5/7] Med: tomcat: Add CATALINA_BASE parameter, defaults 
>>>> >> to CATALINA_HOME, permits multiple tomcat instances
>>>> >>
>>>> >> By exposing the CATALINA_BASE parameter it is possible to have multiple
>>>> >> instances of Tomcat using the same binaries but with each instance 
>>>> >> having its
>>>> >> own configuration, applications etc.
>>>> >>
>>>> >> Existing behaviour is preserved as CATALINA_BASE defaults to 
>>>> >> CATALINA_HOME
>>>> >> which is the default.
>>>> >> ---
>>>> >>  heartbeat/tomcat |   14 +++++++++++++-
>>>> >>  1 files changed, 13 insertions(+), 1 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 723e6d8..1248a97 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -31,6 +31,7 @@
>>>> >>  #   OCF_RESKEY_java_home - Home directory of Java. Default is none
>>>> >>  #   OCF_RESKEY_java_opts - Options to pass to Java JVM for start and 
>>>> >> stop. Default is none
>>>> >>  #   OCF_RESKEY_catalina_home - Home directory of Tomcat. Default is 
>>>> >> none
>>>> >> +#   OCF_RESKEY_catalina_base - Base directory of Tomcat. Default is 
>>>> >> OCF_RESKEY_catalina_home
>>>> >>  #   OCF_RESKEY_catalina_pid  - A PID file name of Tomcat. Default is 
>>>> >> OCF_RESKEY_catalina_home/logs/catalina.pid
>>>> >>  #   OCF_RESKEY_tomcat_start_opts - Start options of Tomcat. Default is 
>>>> >> none.
>>>> >>  #   OCF_RESKEY_catalina_opts - CATALINA_OPTS environment variable. 
>>>> >> Default is none.
>>>> >> @@ -151,6 +152,7 @@ start_tomcat()
>>>> >>                       export JAVA_HOME=${JAVA_HOME}
>>>> >>                       export JAVA_OPTS="${JAVA_OPTS}"
>>>> >>                       export CATALINA_HOME=${CATALINA_HOME}
>>>> >> +                     export CATALINA_BASE=${CATALINA_BASE}
>>>> >>                       export CATALINA_PID=${CATALINA_PID}
>>>> >>                       export CATALINA_OPTS="${CATALINA_OPTS}"
>>>> >>                       $CATALINA_HOME/bin/catalina.sh start 
>>>> >> ${TOMCAT_START_OPTS}
>>>> >> @@ -185,6 +187,7 @@ stop_tomcat()
>>>> >>                       export JAVA_HOME=${JAVA_HOME}
>>>> >>                       export JAVA_OPTS="${JAVA_OPTS}"
>>>> >>                       export CATALINA_HOME=${CATALINA_HOME}
>>>> >> +                     export CATALINA_BASE=${CATALINA_BASE}
>>>> >>                       export CATALINA_PID=${CATALINA_PID}
>>>> >>                       $CATALINA_HOME/bin/catalina.sh stop
>>>> >>  END_TOMCAT_STOP
>>>> >> @@ -335,6 +338,14 @@ Home directory of Tomcat.
>>>> >>  <content type="string" default="" />
>>>> >>  </parameter>
>>>> >>
>>>> >> +<parameter name="catalina_base" unique="1">
>>>> >> +<longdesc lang="en">
>>>> >> +Instance directory of Tomcat
>>>> >> +</longdesc>
>>>> >> +<shortdesc>Instance directory of Tomcat, defaults to 
>>>> >> catalina_home</shortdesc>
>>>> >> +<content type="string" default="" />
>>>> >> +</parameter>
>>>> >> +
>>>> >>  <parameter name="catalina_pid" unique="1">
>>>> >>  <longdesc lang="en">
>>>> >>  A PID file name for Tomcat.
>>>> >> @@ -410,6 +421,7 @@ 
>>>> >> RESOURCE_STATUSURL="${OCF_RESKEY_statusurl-http://127.0.0.1:8080}";
>>>> >>  JAVA_HOME="${OCF_RESKEY_java_home}"
>>>> >>  JAVA_OPTS="${OCF_RESKEY_java_opts}"
>>>> >>  CATALINA_HOME="${OCF_RESKEY_catalina_home}"
>>>> >> +CATALINA_BASE="${OCF_RESKEY_catalina_base-${OCF_RESKEY_catalina_home}}"
>>>> >>  CATALINA_PID="${OCF_RESKEY_catalina_pid-$CATALINA_HOME/logs/catalina.pid}"
>>>> >>
>>>> >>  TOMCAT_START_OPTS="${OCF_RESKEY_tomcat_start_opts}"
>>>> >> @@ -418,7 +430,7 @@ 
>>>> >> CATALINA_ROTATE_LOG="${OCF_RESKEY_catalina_rotate_log-NO}"
>>>> >>  CATALINA_ROTATETIME="${OCF_RESKEY_catalina_rotatetime-86400}"
>>>> >>  SEARCH_STR="\\""${CATALINA_OPTS}"
>>>> >>
>>>> >> -export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_PID CATALINA_OPTS
>>>> >> +export JAVA_HOME JAVA_OPTS CATALINA_HOME CATALINA_BASE CATALINA_PID 
>>>> >> CATALINA_OPTS
>>>> >>
>>>> >>  JAVA=${JAVA_HOME}/bin/java
>>>> >>
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > OK.
>>>> >
>>>> >> From b4f9901de0d87cd380dac690fc1f274e526ce53f Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 14:47:48 +0000
>>>> >> Subject: [PATCH 6/7] Med: tomcat: add timeout to monitor operation
>>>> >>
>>>> >> wget is used as part of monitor operation, ensure timeout specified in
>>>> >> configuration is obeyed. This is also used during start operation, use
>>>> >> hard-coded 1s timeout for that (since its only meant to determine if
>>>> >> service is running or not).
>>>> >> ---
>>>> >>  heartbeat/tomcat |   15 ++++++++++-----
>>>> >>  1 files changed, 10 insertions(+), 5 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index 1248a97..dd4ea12 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -68,6 +68,7 @@ action:
>>>> >>
>>>> >>  ############################################################################
>>>> >>  # Check tomcat service availability
>>>> >> +# $1 is timeout
>>>> >>  isrunning_tomcat()
>>>> >>  {
>>>> >>       if ! have_binary $WGET; then
>>>> >> @@ -75,7 +76,9 @@ isrunning_tomcat()
>>>> >>               ocf_log info "Please make sure that wget is available"
>>>> >>               return $OCF_ERR_CONFIGURED
>>>> >>       fi
>>>> >> -     $WGET -O /dev/null $RESOURCE_STATUSURL >/dev/null 2>&1
>>>> >> +     $WGET -O /dev/null -q -T $1 $RESOURCE_STATUSURL >/dev/null 2>&1 
>>>> >> || return $OCF_ERR_GENERIC
>>>> >> +
>>>> >> +     return $OCF_SUCCESS
>>>> >>  }
>>>> >>
>>>> >>  ############################################################################
>>>> >> @@ -84,15 +87,17 @@ isalive_tomcat()
>>>> >>  {
>>>> >>       pgrep -f "${SEARCH_STR}" > /dev/null
>>>> >>  }
>>>> >> +
>>>> >>  ############################################################################
>>>> >>  # Check tomcat process and service availability
>>>> >> +# $1 is timeout
>>>> >>  monitor_tomcat()
>>>> >>  {
>>>> >> +     MONITOR_TIMEOUT=${1-1}
>>>> >> +
>>>> >>       isalive_tomcat ||
>>>> >>               return $OCF_NOT_RUNNING
>>>> >> -     isrunning_tomcat ||
>>>> >> -             return $OCF_NOT_RUNNING
>>>> >> -     return $OCF_SUCCESS
>>>> >> +     isrunning_tomcat $MONITOR_TIMEOUT
>>>> >>  }
>>>> >>
>>>> >>  ############################################################################
>>>> >> @@ -463,7 +468,7 @@ case "$COMMAND" in
>>>> >>               ;;
>>>> >>       monitor)
>>>> >>               #ocf_log debug  "[$TOMCAT_NAME] Enter tomcat monitor"
>>>> >> -             monitor_tomcat
>>>> >> +             monitor_tomcat ${OCF_RESKEY_CRM_timeout}
>>>> >
>>>> > This should be $((OCF_RESKEY_CRM_meta_timeout / 1000)).
>>>>
>>>> Oops!
>>>>
>>>> >
>>>> >>               func_status=$?
>>>> >>               #ocf_log debug  "[$TOMCAT_NAME] Leave tomcat monitor 
>>>> >> $func_status"
>>>> >>               exit $func_status
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > If wget doesn't finish within OCF_RESKEY_CRM_meta_timeout, the
>>>> > monitor operation will timeout and it would be cleaned up by
>>>> > lrmd. Actually, it's better if the error is reported as timeout
>>>> > rather than generic error. So, I'd rather skip this patch,
>>>> > unless you give me better arguments :)
>>>>
>>>> Not going to argue but would like to discuss a little and will defer
>>>> to your judgement:
>>>> monitor_tomcat is used in three places:
>>>> (a) During the monitor operation
>>>> (b) At the beginning of the start operation, to test if tomcat is
>>>> already running (thereby skipping start operation)
>>>> (c) At the end of the start operation, to ensure its running properly
>>>> (confirmed start).
>>>
>>> It is only this last point which may make a difference.
>>
>> To me, the only real evidence that Tomcat has started successfully is the
>> output of a particular line in the Tomcat logs:
>> 2011-01-14 17:21:46,104  INFO main startup.Catalina:589 - Server
>> startup in 49856 ms
>>
>> At this point, Tomcat is running and applications have been started and are 
>> past
>> the initial 'startup' phase and are now ready to receive requests.
>>
>> This is very difficult to monitor however as Tomcat can have many different
>> log files using many different log formats and only one of them might
>> contain the necessary
>> line. :(
>>
>>>
>>>> Without explicitly specifying a timeout wget may block for a length of
>>>> time that might exceed
>>>> the timeout of the operation (monitor or start).
>>>>
>>>> Reasons wget might block:
>>>> 1. target IP can't be reached (should be the server running tomcat but
>>>> you never know)
>>>> 2. request sent but response not received (i.e. busy)
>>>> 3. numerous others...
>>>>
>>>> Is the result of wget's operation important enough to be communicated
>>>> back to Pacemaker?
>>>> Will it help Pacemaker make a decision?
>>>
>>> Well, if immediately after start wget may block unnecessarily
>>> thus wasting precious time, a wget timeout could be in order.
>>> But note that if it's too short it could make wget repeatedly
>>> timeout and make the start action fail. It would be difficult to
>>> gauge what kind of timeout is safe. At any rate, 1 second looks
>>> dangerous to me. Any value would for that matter, since it
>>> depends on the application, right?
>>
>> Yes. It certainly would, perhaps it would be better to merely check
>> for 'process active'
>> rather than full status check at the start.
>>
>> A subsequent normal 'status' operation (with its proper timeout) could
>> determine if
>> the process is working or not.
>>
>> Does that fit with normal operation?
>>
>>>
>>>> >> From 67cbaeed384a9b2db61ccca44751c100a8a66e07 Mon Sep 17 00:00:00 2001
>>>> >> From: Brett Delle Grazie <bdellegra...@iee.org>
>>>> >> Date: Tue, 18 Jan 2011 15:46:26 +0000
>>>> >> Subject: [PATCH 7/7] Med: tomcat: Use Tomcat stop TIMEOUT -force to 
>>>> >> improve stop
>>>> >>
>>>> >> The tomcat stop script can be told to forcefully terminate tomcat if it
>>>> >> doesn't shut down nicely within a specified period. Using this reduces
>>>> >
>>>> > Has this been true for all supported tomcat releases?
>>>>
>>>> Since at least 09/2004 (5.0.28)
>>>>
>>>> Note that 5.0.x is no longer supported by Tomcat
>>>> Versions 5.5.x, 6.0.x and 7.0.x all have it in there.
>>>
>>> OK.
>>>
>>>> >> the stop case to almost a simple 'call tomcat stop script in blocking
>>>> >> mode'.  The timeout is set to slightly shorter than the stop operation
>>>> >> timeout. The tomcat stop script checks for and uses the PID file.
>>>> >> ---
>>>> >>  heartbeat/tomcat |   67 
>>>> >> ++++++++---------------------------------------------
>>>> >>  1 files changed, 10 insertions(+), 57 deletions(-)
>>>> >>
>>>> >> diff --git a/heartbeat/tomcat b/heartbeat/tomcat
>>>> >> index dd4ea12..8fb2b2b 100755
>>>> >> --- a/heartbeat/tomcat
>>>> >> +++ b/heartbeat/tomcat
>>>> >> @@ -24,8 +24,6 @@
>>>> >>  # OCF parameters:
>>>> >>  #   OCF_RESKEY_tomcat_name - The name of the resource. Default is 
>>>> >> tomcat
>>>> >>  #   OCF_RESKEY_script_log  - A destination of the log of this script. 
>>>> >> Default /var/log/OCF_RESKEY_tomcat_name.log
>>>> >> -#   OCF_RESKEY_tomcat_stop_timeout  - Time-out at the time of the 
>>>> >> stop. Default is 5
>>>> >> -#   OCF_RESKEY_tomcat_suspend_trialcount  - The re-try number of times 
>>>> >> awaiting a stop. Default is 10
>>>> >>  #   OCF_RESKEY_tomcat_user  - A user name to start a resource. Default 
>>>> >> is root
>>>> >>  #   OCF_RESKEY_statusurl - URL for state confirmation. Default is 
>>>> >> http://127.0.0.1:8080
>>>> >>  #   OCF_RESKEY_java_home - Home directory of Java. Default is none
>>>> >> @@ -180,12 +178,19 @@ END_TOMCAT_START
>>>> >>  # Stop Tomcat
>>>> >>  stop_tomcat()
>>>> >>  {
>>>> >> +     TOMCAT_STOP_TIMEOUT=${OCF_RESKEY_CRM_timeout-5}
>>>> >
>>>> > Again, this should be $((OCF_RESKEY_CRM_meta_timeout / 1000)).
>>>>
>>>> Oops!
>>>>
>>>> >
>>>> >> +     if [ $TOMCAT_STOP_TIMEOUT -gt 1 ]; then
>>>> >
>>>> > This should always evaluate to true. OCF_RESKEY_CRM_meta_timeout
>>>> > is always going to be set, by default to 20000 (20 seconds).
>>>>
>>>> Okay noted, I was being a safety bunny.
>>>>
>>>> >
>>>> >> +         TOMCAT_STOP_TIMEOUT =`expr $TOMCAT_STOP_TIMEOUT - 1`
>>>> >> +     else
>>>> >> +         TOMCAT_STOP_TIMEOUT = 1
>>>> >> +     fi
>>>> >> +
>>>> >>       cd "$CATALINA_HOME/bin"
>>>> >>
>>>> >>       echo "`date "+%Y/%m/%d %T"`: stop  ###########################" 
>>>> >> >> "$TOMCAT_CONSOLE"
>>>> >>
>>>> >>       if [ "$RESOURCE_TOMCAT_USER" = RUNASIS ]; then
>>>> >> -             "$CATALINA_HOME/bin/catalina.sh" stop \
>>>> >> +             "$CATALINA_HOME/bin/catalina.sh" stop 
>>>> >> $TOMCAT_STOP_TIMEOUT -force \
>>>> >>                       >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >>       else
>>>> >>               cat<<-END_TOMCAT_STOP | su - -s /bin/sh 
>>>> >> "$RESOURCE_TOMCAT_USER" >> "$TOMCAT_CONSOLE" 2>&1 &
>>>> >> @@ -194,7 +199,7 @@ stop_tomcat()
>>>> >>                       export CATALINA_HOME=${CATALINA_HOME}
>>>> >>                       export CATALINA_BASE=${CATALINA_BASE}
>>>> >>                       export CATALINA_PID=${CATALINA_PID}
>>>> >> -                     $CATALINA_HOME/bin/catalina.sh stop
>>>> >> +                     $CATALINA_HOME/bin/catalina.sh stop 
>>>> >> $TOMCAT_STOP_TIMEOUT -force
>>>> >>  END_TOMCAT_STOP
>>>> >>       fi
>>>> >>
>>>> >> @@ -202,40 +207,7 @@ END_TOMCAT_STOP
>>>> >>       while isalive_tomcat; do
>>>> >>               sleep 1
>>>> >>               lapse_sec=`expr $lapse_sec + 1`
>>>> >> -             ocf_log debug "stop_tomcat[$TOMCAT_NAME]: stop NORM 
>>>> >> $lapse_sec/$TOMCAT_STOP_TIMEOUT"
>>>> >> -             if [ $lapse_sec -ge $TOMCAT_STOP_TIMEOUT ]; then
>>>> >> -                     break
>>>> >> -             fi
>>>> >> -     done
>>>> >> -
>>>> >> -     if isalive_tomcat; then
>>>> >> -             lapse_sec=0
>>>> >> -             while true; do
>>>> >> -                     sleep 1
>>>> >> -                     lapse_sec=`expr $lapse_sec + 1`
>>>> >> -                     ocf_log debug "stop_tomcat[$TOMCAT_NAME]: suspend 
>>>> >> tomcat by SIGTERM ($lapse_sec/$TOMCAT_SUSPEND_TRIALCOUNT)"
>>>> >> -                     pkill -TERM -f "${SEARCH_STR}"
>>>> >> -                     if isalive_tomcat; then
>>>> >> -                             ocf_log debug "stop_tomcat[$TOMCAT_NAME]: 
>>>> >> suspend tomcat by SIGQUIT ($lapse_sec/$TOMCAT_SUSPEND_TRIALCOUNT)"
>>>> >> -                             pkill -QUIT -f "${SEARCH_STR}"
>>>> >> -                             if isalive_tomcat; then
>>>> >> -                                     if [ $lapse_sec -ge 
>>>> >> $TOMCAT_SUSPEND_TRIALCOUNT ]; then
>>>> >> -                                             break
>>>> >> -                                     fi
>>>> >> -                             else
>>>> >> -                                     break
>>>> >> -                             fi
>>>> >> -                     else
>>>> >> -                             break
>>>> >> -                     fi
>>>> >> -             done
>>>> >> -     fi
>>>> >> -
>>>> >> -     lapse_sec=0
>>>> >> -     while isalive_tomcat; do
>>>> >> -             sleep 1
>>>> >> -             lapse_sec=`expr $lapse_sec + 1`
>>>> >> -             ocf_log debug "stop_tomcat[$TOMCAT_NAME]: suspend tomcat 
>>>> >> by SIGKILL ($lapse_sec)"
>>>> >> +             ocf_log debug "stop_tomcat[$TOMCAT_NAME]: stop failed, 
>>>> >> killing with SIGKILL ($lapse_sec)"
>>>> >>               pkill -KILL -f "${SEARCH_STR}"
>>>> >>       done
>>>> >>
>>>> >> @@ -286,23 +258,6 @@ Log file, used during start and stop operations.
>>>> >>  <content type="string" default="" />
>>>> >>  </parameter>
>>>> >>
>>>> >> -<parameter name="tomcat_stop_timeout" unique="0">
>>>> >> -<longdesc lang="en">
>>>> >> -Time-out for stop operation.
>>>> >> -</longdesc>
>>>> >> -<shortdesc>Time-out for the stop operation</shortdesc>
>>>> >> -<content type="integer" default="" />
>>>> >> -</parameter>
>>>> >> -
>>>> >> -<parameter name="tomcat_suspend_trialcount" unique="0">
>>>> >> -<longdesc lang="en">
>>>> >> -Maximum number of times to retry stop operation before suspending
>>>> >> -and killing Tomcat.
>>>> >> -</longdesc>
>>>> >> -<shortdesc>Max retry count for stop operation</shortdesc>
>>>> >> -<content type="integer" default="" />
>>>> >> -</parameter>
>>>> >> -
>>>> >>  <parameter name="tomcat_user" unique="0">
>>>> >>  <longdesc lang="en">
>>>> >>  The user who starts Tomcat.
>>>> >> @@ -418,8 +373,6 @@ validate_all_tomcat()
>>>> >>
>>>> >>  TOMCAT_NAME="${OCF_RESKEY_tomcat_name-tomcat}"
>>>> >>  TOMCAT_CONSOLE="${OCF_RESKEY_script_log-/var/log/$TOMCAT_NAME.log}"
>>>> >> -TOMCAT_STOP_TIMEOUT="${OCF_RESKEY_tomcat_stop_timeout-5}"
>>>> >> -TOMCAT_SUSPEND_TRIALCOUNT="${OCF_RESKEY_tomcat_suspend_trialcount-10}"
>>>> >>  RESOURCE_TOMCAT_USER="${OCF_RESKEY_tomcat_user-RUNASIS}"
>>>> >>  RESOURCE_STATUSURL="${OCF_RESKEY_statusurl-http://127.0.0.1:8080}";
>>>> >>
>>>> >> --
>>>> >> 1.7.1
>>>> >>
>>>> >
>>>> > Of the answer to the above question is yes, then I'd like to see
>>>> > this patch go in as well. Unless somebody objects. We'd need
>>>> > though to keep the parameters for the time being. The first one
>>>> > may get obsoleted in future, and the second one simply ignored
>>>> > until obsoleted.
>>>>
>>>> Sounds good to me.
>>>
>>> OK. Could you please produce new patch which would keep the
>>> obsolete parameters, but mark them as such in the meta-data.
>>> That way we can keep the existing installations happy. I guess
>>> that you could anyway use the meta timeout parameter, it would
>>> anyway need to be set to something higher than
>>> tomcat_stop_timeout.
>
> Will do.

Stupid question #1: how do I mark a parameter as obsolete / deprecated in
the meta-data - is there an attribute to add? Or just add text saying obsolete?

>
>>>
>>>> > Patches 1-5 are pushed. Is there anything else? Oh, and did you
>>>> > test the changes thoroughly?
>>>>
>>>> The changes have been in use in production on client systems for the
>>>> past 6 months.
>>>> This doesn't mean there aren't bugs - it just means they haven't come
>>>> across them yet.
>>>> e.g. my mistake with the timeouts.
>>>
>>> Good. But note that your timeout is always set to 4 seconds.
>
> Yes noted, will correct.
>
>>> BTW, what does catalina.sh do when this times out, uses kill -9?
>
> Yes it does.
>
>>>
>>> Cheers,
>>>
>>> Dejan
>>>
>>>> > Many thanks for the contribution!
>>>>
>>>> You're welcome, it was a pleasure to be able to contribute something
>>>> back for a change.
>>>>
>>>> >
>>>> > Cheers,
>>>> >
>>>> > Dejan
>>>> >
>>>>
>>>> --
>>>> Best Regards,
>>>>
>>>> Brett Delle Grazie
>>>> _______________________________________________
>>>> Linux-HA mailing list
>>>> Linux-HA@lists.linux-ha.org
>>>> http://lists.linux-ha.org/mailman/listinfo/linux-ha
>>>> See also: http://linux-ha.org/ReportingProblems
>>> _______________________________________________
>>> Linux-HA mailing list
>>> Linux-HA@lists.linux-ha.org
>>> http://lists.linux-ha.org/mailman/listinfo/linux-ha
>>> See also: http://linux-ha.org/ReportingProblems
>>>
>>
>>
>>
>> --
>> Best Regards,
>>
>> Brett Delle Grazie
>>
>
>
>
> --
> Best Regards,
>
> Brett Delle Grazie
>



-- 
Best Regards,

Brett Delle Grazie
_______________________________________________
Linux-HA mailing list
Linux-HA@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to