On Fri, Mar 18, 2011 at 22:45, Christopher Schultz
<[email protected]> wrote:
[...]
>
> I'm interested to see how you are able to launch Tomcat and have your
> script continue only after all webapps have been deployed.
>
This is the code right now:
----
if [ "$1" = "start" ]; then
STARTDATE=$(date +%Y%m%d-%H%M)
STAMP="=== START $STARTDATE ==="
cat >>"$LOGFILE" <<EOF
$STAMP
EOF
echo -n "Starting Tomcat"
${JAVACMD} $JAVA_STARTUP_OPTS $JAVA_OPTS \
-classpath "$CLASSPATH" $TOMCAT_OPTS \
"$MAIN_CLASS" start >> "$LOGFILE" 2>&1 &
echo $! > $CATALINA_PID
MAXITERS=120
ITERS=0
while true; do
ITERS=$((ITERS+1))
if [ $ITERS -gt $MAXITERS ]; then
echo
echo >&2 "BUG: Tomcat not started after
$MAXITERS seconds!"
exit 1
fi
perl -ne "print if /^$STAMP$/ .. eof()" "$LOGFILE" | \
egrep -q "^INFO: Server startup in [0-9]+ ms$"
RC=$?
if [ "$RC" = "0" ]; then
break
fi
echo -n .
sleep 1
done
echo " Done (in $ITERS seconds)"
[...]
----
It is with this script that I noticed the long deploying time of
/manager. This is the only way I knew of until yesterday, when I
noticed that the shutdown port only gets open after webapps are
deployed. I'll switch to this technique (using netstat -ltn|grep -w
$SHUTDOWN_PORT or something like that) since it is more reliable (and
faster) than scanning the log file: the server startup message may
change behind me... Ideally, of course, it'd be very nice if the
BootStrap class had, said, a "fullstart" command: I wouldn't need any
of these ;)
Ultimately, what I really want to do anyway is a startup sequence
which starts Tomcat up only with the manager app, and which deploys
webapps the list of which I store in another place. The deploy command
only returns after the app is fully deployed, which is good (and so
does the undeploy command).
[...]
>
>> Third, what if you want to do SNMP monitoring
>> (-Dcom.sun.management.snmp.port=xxx etc etc)? You can't with the
>> bundled scripts. Why? If you set JAVA_OPTS appropriately, these
>> JAVA_OPTS will also be used for shutdown... Which means you can't
>> shutdown at all: EADDRINUSE. Unless you arrange for different
>> JAVA_OPTS on startup and shutdown, which I don't need to do with my
>> scripts.
>
> As Chuck suggests, you haven't read the documentation well enough
> because catalina.sh has options to cover your situation described above.
>
Indeed.
--
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 683 877 875
Tel : +33 (0) 178 945 552
[email protected]
40 avenue Raymond Poincaré
75116 Paris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]