Listing 1: Restart the Netscape http server daemon
# Ensure the Netscape server is running, restart if it's not.
# The server consists of several ns_httpd processes but the lead
# process is the one to be most concerned about. Locate it's pid and
# ensure that there is a process with that pid and that its name is
# ns_httpd
# Can add a for loop to watch over more than one daemon; a ppp
# daemon might be another important one to watch.
set daemon ns-httpd
set pid_file /usr/internet/ns_httpd/httpd-80/logs/pid
set daemon_start "cd /usr/internet/ns_httpd/httpd080\; exec sh -c \
./start"
set found 0
set failed 0
set fd [open $pid_file r]
set pid [read -nonewline $fd]
close $fd
dget process
forrow $DBNAME process currentRow {
if { [dget -n process pid $currentRow] == $pid } {
if { [dget -n process name $currentRow] == $daemon } {
set found 1
}
break
}
}
if {! $found} {
if {[catch {eval $daemon_start}]} {
set failed 1
}
}
# End of File
|