NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_atsignal(n) 4.99.30 naviserver "NaviServer Built-In Commands"

Name

ns_atsignal - Server callbacks

Table Of Contents

Synopsis

Description

These commands provide hooks for you to register your own procedures to be called during the different stages of the server processes lifetime.

You can find out which callbacks are already registered with the ns_info callbacks command. Further callbacks can be registered via ns_ictl trace.

COMMANDS

ns_atprestartup script ?args?

Pre-startup procs are called in FIFO order after the configuration file has been parsed and all modules loaded, but before the driver starts listening for and processing connections.

ns_atstartup script ?args?

Startup procs are called in FIFO order just after the server is fully initialized and is listening for and processing connections.

ns_atsignal script ?args?

Signal procs are called in FIFO order whenever a HUP signal is received by the server process.

The following example shows how to log the accumulated cache statistics and reset whenever the server is signaled.

 ns_atsignal {
   foreach cache [ns_cache_names] {
      ns_log notice "cache\[$cache\]: [ns_cache_stats -reset -- $cache]"
   }
 }
ns_atshutdown script ?args?

At-shutdown procs are called in LIFO order when the server performs a controlled shutdown after all other subsystem have been stopped.

Orderly shutdown is attempted within shutdowntimeout, as specified in the configuration file. Tcl shutdown procs are called before C shutdown tasks are waited on, so should be well-behaved.

Do not attempt to use other subsystems for shutdown jobs, such as the ns_job command.

ns_atexit script ?args?

At-exit procs are called in LIFO order after all shutdown procs have been called and the server process is ready to exit. The atexit procs are basically the last code to run.

See Also

ns_atclose, ns_ictl, ns_info, ns_runonce

Keywords

callback, exit, global built-in, shutdown, signal, startup