> Submitted By: Zoran Vasiljevic (vasiljevic)
> Summary: Server instance controller process
>
> Initial Comment:
> Since some time we have added an option to nsd to fork
> twice instead of once when putting itself in the background.
> This way we have created one additional server instance
> which is now able to monitor the actual server and restart
> it in the case of failure. This has proven very convenient,
> yet simple to do. Far more simple than fiddling with the
> inittab and init machinery. It is just a matter of giving one
> more startup option to the command starting the server.
>
> Now, I'm being tired to patch this simple change in the
> nsmain.c each time and I think that this would be interesing
> for other nsd users as well.
>
> I would like to get this into the regular distribution and if there
> are any voices against, please step out.
> Again, this change has no implications on the regular server
> operation and is conveniently selectable.

I think as long as this is kept as a command line switch, I think
there's no reason not to.

My personal solution to this is to run the nsd process from a shell
script.  In the shell script, there's a infinite while loop, and the
body of the loop runs nsd under strace (in Linux) or truss (in Solaris).
I do this so that it can run in the background (IOW, avoiding having to
use -f in the script) so that nsd logs to log/server.log instead of
the console (then having to redirect it in the shell script back into
log/server.log).

When the nsd exits (dies gracefully, or segfaults, or whatever) control
resumes in the shell script.  So, when I shut down nsd, what I do is rm
the log/nspid.${servername} file before issuing the nsd -K to shut it
down.  When strace/truss exit, the shell script looks to see if the
pidfile exists.  If it does, then nsd exited abnormally, and the while
loop starts over and re-runs nsd.  If the file doesn't exist, a break is
issued and the shell script terminates.

This might feel kludgy to some folks, but I've been running webservers
like this for ages -- I believe Netscape Enterprise Server even ships
with its start/stop scripts doing this!  Of course, they also have some
kind of watchdog process that runs as well, but I'm not 100% sure what
that process actually does ... ;-)

As I said, I think implementing this directly in code with a
user-selectable command line switch might be really convenient.  But,
it's obviously not necessary to achieve the same results ... as you can
do it simply with a 8 line shell script.

-- Dossy

--
Dossy Shiobara                       mail: [EMAIL PROTECTED]
Panoptic Computer Network             web: http://www.panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)


--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list: http://www.aolserver.com/listserv.html
List information and options: http://listserv.aol.com/

Reply via email to