Heartbeat script in Perl
Archive - Originally posted on "The Horse's Mouth" - 2007-02-09 17:28:03 - Graham EllisScenario ... an Apache httpd web server is distributing requests around between a number of Apache Tomcat instances on different computers (perhaps using mod_rewrite to allocate the requests). If a Tomcat instance become unavailable (i.e. if the host running it is taken offline) then it's to be removed from the pool, and if it comes back on line it's to be added to the pool again.
Sound complex? The basis can be quite a simple Perl script such as the one we wrote during today's course - source code here.
A regular ping around the machines that may be in the pool establishes which are present, and if the availabiity has changed the RewriteMap is rewritten. Place a pause of a few seconds into the loop and try again ....