Thanks.

I would recommend changing the kill line to:

        killall $POUND_BIN

just for people like me to accidentally on purpose save the script to /etc/init.d/pound.  Otherwise the script kills itself as well as the running pound.

For my contribution, here is a small TCL script which interfaces with the haPort mechanism.  The idea is that this script is run from the same script that starts the server being balanced just after the server starts accepting connections.  It then loads several URLs' contents in order to warm up the server and only after getting those pages advertises that the server is up.

This strategy helps avoids the problem of a server with a long startup timing out on initial requests.  It also helps with the similar problem if you are using substantial amounts of caching ... you may not want your server to handle full loads right off the bat.  Translating this into your favorite scripting language should be trivial.

I still don't think that the haPort strategy itself is failsafe and would rather see a polling of a priority server, but this will do just fine for now.  All of our main server run scripts now incorporate this watchdog.

#!/usr/bin/tclsh

package require http

# handle command line arguments
if {$argc != 4} {
    puts stderr "Usage: watchdog server-host server-port url-file haPort"
}
set host [lindex $argv 0]
set port [lindex $argv 1]
set urlFile [lindex $argv 2]
set haPort [lindex $argv 3]

# write a suicide note to make it easier to kill us
set f [open watchDog.pid w]
puts $f [pid]
close $f

# read the warmup URLs
set f [open $urlFile]
set urls {}
while {[gets $f url] >= 0} {
    lappend urls $url
}

# access each in turn
foreach x $urls {
    puts "getting http://$host:$port/$x"
    set t [http::geturl http://$host:$port/$x]
    puts "  status = [http::status $t]"
    http::cleanup $t
}
 
# callback for incoming connections
proc acceptConnection {s h p} {
    puts "Connection from $h @ [ clock format [ clock seconds ] ]"
    close $s
}

# start accepting connections ... this tells pound the server is ready
set s [socket -server acceptConnection $haPort ]

# never exit but do enter the event loop ... this is just a tcl-ism
set x 0
vwait x




Sergio Freire wrote:
Please find attached two init scripts for /etc/rc.d/init.d:

-          one for pound 1.xx

-          one for pound 2.xx
  


-- 
Ted Dunning
Chief Scientist
Veoh Networks