MonitorPatch Direct Actions

The following direct actions were added to Monitor. They might be useful for creating scripts to automate deployments of new WO application versions. (First time deployments and config changes would still require interactive sessions in Monitor.) Each direct action returns a short string (instead of a full HTML page) and an HTTP status code indicating whether the respective action was executed successfully. If Monitor is password-protected, these direct actions are not permitted to be executed.

Direct Action Return Values Description
running 'YES', 'NO', or
error message
checks whether instances are running (alive)
stopped checks whether instances have stopped (are dead)
start 'OK' or
error message
attempts to start instances which have been stopped or are stopping
stop attempts to stops instances which are running or starting
forceQuit stops instances forcefully
turnAutoRecoverOn 'OK' or
error message
turns Auto Recover on
turnAutoRecoverOff turns Auto Recover off
turnRefuseNewSessionsOn 'OK' or
error message
turns Refuse New Sessions on
turnRefuseNewSessionsOff turns Refuse New Sessions off
turnScheduledOn 'OK' or
error message
turns Scheduled on
turnScheduledOff turns Scheduled off
clearDeaths 'OK' or
error message
sets the number of deaths to 0

All direct actions must be invoked with a type

Type Description Requires Names
all all instances of all applications no
app all instances of the specified applications yes
ins all the specified instances

Possible status codes

Code Circumstance
200 (OK) return value is 'OK' or 'YES'
403 (Unauthorized) Monitor is password protected
404 (Not Found) one or more of the supplied application or instance names can't be found
406 (Not Acceptable) an unknown type is supplied, or names are required but missing
417 (Not Expected) return value is 'NO'
500 (Error) software defect (please send stacktrace from Monitor's log)

Examples

URL Description
.../JavaMonitor.woa/wa/start?type=app&name=AppleStore&name=MemberSite Starts all instances of the AppleStore and the MemberSite applications. Returns error if any of these applications are unknown to Monitor, OK otherwise.
.../JavaMonitor.woa/wa/turnScheduledOff?type=all Turns scheduling off for all instances of all applications, then returns OK.
.../JavaMonitor.woa/wa/stopped?type=ins&name=AppleStore-4&name=MemberSite-8&name=AppleStore-2 Returns YES if the instances 2 and 4 of the AppleStore and instance 8 of the MemberSite are all dead. Returns NO if at least one of them has not stopped. Returns error if any of these instances are unknown to Monitor.

Simple deployment script

#!/bin/sh

# clean build
ant clean install

# run unit tests
ant test

# stop application
result=`curl -s http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/wa/stop\?type=app\&name=MemberSite`
[ "$result" = OK ] || { echo $result; exit 1; }

# deploy new application
scp -rq /Library/WebObjects/Applications/MemberSite.woa bigserver:/Library/WebObjects/Applications/

# start application
result=`curl -s http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/wa/start\?type=app\&name=MemberSite`
[ "$result" = OK ] || { echo $result; exit 1; }

echo "deployment completed"

Invoking direct actions manually

curl -w " (status: %{http_code})\n" http://bigserver:1086/cgi-bin/WebObjects/JavaMonitor.woa/wa/forceQuit\?type=ins\&name=AppleStore-3