NaviServer now has implemented a quite useful "watchdog" feature that allows the server to restart if it fails. In many situations you are now freed from setting up a special way of handling a server failure that would be solved with a simple restart.
Just start the server with the new "-w" switch.
Technically speaking the nsd process is forked twice and the first forked instance (the watchdog) controls the second (the worker). The first instance reacts on exit codes and signals caught during the watch and correspondingly restarts the second instance.
To restart the server from within your TCL code:
To restart the server from the shell you can send the server the SIGINT.
There are several ways to keep your server running. Depending on your particular requirements the watchdog may not be the right thing for you. Common approaches are listed below.
Very easy to setup but with it's own limitations. init is the parent of all processes. It creates processes from the script /etc/inittab. Add a line like
ns1:345:respawn:/usr/local/ns/bin/nsd -i -u nsadmin -g users -t /usr/local/ns/config.tcl
and init does the job of restarting the server if it crashes.
As you already have (or may have) a rc-script for starting your server during boot time you simply could run a cronjob that checks the status of something like
rcnaviserver status || rcnaviserver start
as part of a script every 5 minutes by adding a crontab line (crontab -e) like
*/5 * * * * /root/cronjobs/nsd_crontab
Daemontools is a collection of software to control other processes.