We use Tomcat as well, I use the following irule for when we do deploy's.
when CLIENT_ACCEPTED {
set myretry 0
}
when HTTP_REQUEST {
set myrequest [HTTP::request]
}
when HTTP_RESPONSE {
if { [HTTP::status] == 503 }{
if {($myretry < 3) } {
log "got a 500... retrying, myretry == $myretry The request was $myrequest"
incr myretry
HTTP::retry $myrequest
}
else {
log "Going to maint because all servers are serving 503's, myretry == $myretry"
HTTP::redirect http://maint.my.com/
}
}
}
when LB_FAILED {
set mypool [LB::server]
log "$mypool seems to be having a problem..., going to the maint page myretry == $myretry"
log "$myrequest"
if { [active_members $mypool] < 1 } {
log "Going to maint because all servers are down"
HTTP::redirect http://maint.my.com/
}
}