NaviServer - programmable web server

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

# ns_atsignal(n) 4.99.8 naviserver "NaviServer Built-In Commands"

## Name

ns_atsignal - Server callbacks

## Table Of Contents

## Synopsis

- ns_atprestartup script ?args?
- ns_atstartup script ?args?
- ns_atsignal script ?args?
- ns_atshutdown script ?args?
- ns_atexit script ?args?

## 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.

## 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 initialised 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.

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 seconds, 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 sub-systems, 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.

## EXAMPLES

Log the accumulated cache statistics and reset whenever the server is signalled:

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

## See Also

ns_atclose, ns_atexit, ns_atshutdown, ns_info

## Keywords

callback, signal