mud-nanny-0.1/
MUD Nanny
Sean Middleditch / AwesomePlay Productions, Inc.
elanthis@awemud.net
THIS IS PUBLIC DOMAIN
================================================

The main binary, mud-nanny, takes only two parameters: the first one is
the MUD to run, and the second is a path to an event handling script.  It
is currently not possible to pass arguments to the MUD.

NOTE: you can emulate the passing of arguments to the MUD by giving MUD
Nanny the path to a script instead of the MUD itself.  The script can
start the MUD using the exec command.

The MUD will be started.  When it finishes running, MUD Nanny will then
call the event script and tell it how the MUD exited, the exit code or
terminating signal number, and how many seconds the MUD was up.

NOTE: the MUD must not try to daemonize itself (that is, it must not call
fork() during startup).  That will cause MUD Nanny to think that the MUD
has exited.

The event script may then do whatever it pleases; log the results, send
emails, start other programs, or even sleep.  When the event script exits,
MUD Nanny will restart the MUD, if the script exit code was 0 (the default).
If the script's exit status was non-zero, then MUD Nanny will shutdown.

The default script will send an email to the user.  Then, if the MUD's
uptime was less than 30 seconds, the script will sleep for 15 minutes.  This
is to prevent a MUD which is crashing at startup from eating up all the CPU
time.  If the MUD exited with an exit code of 0, or if the script was
terminated with signal 15 (SIGTERM), then the script will return non-zero and
MUD Nanny will shutdown; otherwise, the script returns 0 and MUD Nanny will
restart the MUD.

TODO:
- allow passing arguments to the MUD
- improve the default event script to track state and/or log events
- add a helper daemon, mudbrbd (Be Right Back Daemon), which will listen to
  a port and display a BRB message to anyone who connects; this is useful if
  the script wants to sleep for a while, as this way users who try to connect
  to the MUD while it's down won't get an irritating and completely
  uninformative "connection refused" error
- add proper signal handling to MUD Nanny so it's more robust