Difference between revisions of "Nsproxy"

From AOLserver Wiki
Jump to navigation Jump to search
Line 9: Line 9:
 
'''DESCRIPTION'''
 
'''DESCRIPTION'''
  
: This command provides a simple, robust proxy mechanism to evaluate Tcl scripts in a separate, pipe-connected process. This approach can be useful both to isolate potentially thread-unsafe code outside the address space of a multithreaded process such as NaviServer or to enable separation and timeout of potentially misbehaving, long running scripts.  
+
: This command provides a simple, robust proxy mechanism to evaluate Tcl scripts in a separate, pipe-connected process. This approach can be useful both to isolate potentially thread-unsafe code outside the address space of a aolserver or to enable separation and timeout of potentially misbehaving, long running scripts. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.
  
 
: The legal ''option''s are:
 
: The legal ''option''s are:
Line 29: Line 29:
 
: Releases any handles from any pools currently owned by a thread. This command is intended to be used as part of a garbage collection step.
 
: Releases any handles from any pools currently owned by a thread. This command is intended to be used as part of a garbage collection step.
  
* '''ns_proxy config''' ''poolname'' ''?'' '''-init''' ''value? ?'' '''-reinit''' ''value? ?'' '''-min''' ''value? ?'' '''-max''' ''value? ?'' '''-exec''' ''value? ?'' '''-gettimeout''' ''value? ?'' '''-evaltimeout''' ''value? ?'' '''-sendtimeout''' ''value? ?'' '''-recvtimeout''' ''value? ?'' '''-waittimeout''' ''value?  
+
* '''ns_proxy config''' ''poolname'' ''?'' '''-init''' ''script? ?'' '''-reinit''' ''script? ?'' '''-min''' ''value? ?'' '''-max''' ''value? ?'' '''-exec''' ''program? ?'' '''-gettimeout''' ''value? ?'' '''-evaltimeout''' ''value? ?'' '''-sendtimeout''' ''value? ?'' '''-recvtimeout''' ''value? ?'' '''-waittimeout''' ''value?  
  
* '''ns_proxy ping'''
+
: Configure the specified pool. ''init'' can be used to specify a script to be evaluated, when the proxy (slave) is started. ''reinit'' specifies the script to be evaluated when the slave is re-initialized. ''min'' and ''max'' are the minimum and maximum number of slaves.  ''exec'' names the program to be executed (defaults to ''nsproxy''). ''gettimeout'' specifies the maximum time in ms to wait to allocate handles from the pool (default 5000). ''evaltimeout'' specifies the maximum time in ms to wait for a script to be evaluated in a proxy. This parameter can be overridden on a per-call basis with the optional ''timeout'' parameter to '''ns_proxy eval'''. The default is 0 milliseconds i.e. infinite. ''sendtimeout'' and ''recvtimeout' specify the maximum time to wait to send a script and receive a result from a proxy. ''waittimeout'' specifies the maximum time to wait for a proxy to exit.
  
* '''ns_proxy active'''
+
* '''ns_proxy ping''' ''handle''
  
* '''ns_proxy send'''
+
: Check if ''handle'' is alive by sending an empty request.
  
* '''ns_proxy wait'''
+
* '''ns_proxy active''' ''pool''
 +
 
 +
: Returns a list of all currently evaluating scripts in proxies for the given pool. The output is a list which includes two elements, the string name of the proxy handle and the string for the script being executed. It is also possible to view the currently evaluating scripts with the Unix ps command as the proxy slave process re-writes it's command argument space with the request script before evaluation and clears it after sending the result.
 +
 
 +
* '''ns_proxy send''' ''handle script''
 +
 
 +
: Sends ''script'' in the proxy specified by handle. Unlike with '''ns_proxy eval''', this option will return immediately while the script continues to execute in the proxy process. A later ns_proxy wait followed by an '''ns_proxy recv''' is expected.
 +
 
 +
* '''ns_proxy wait''' ''handle ?timeout?''
 +
 
 +
: Waits for a script sent via '''ns_proxy send''' in the proxy specified by the ''handle'' argument to complete. The optional ''timeout'' parameter specifies the number of milliseconds to wait for the script to complete, the default is an indefinite wait.
  
 
* '''ns_proxy recv'''
 
* '''ns_proxy recv'''
 +
 +
: Receives a response from a script that was sent via '''ns_proxy send''' and waited on via '''ns_proxy wait'''.
  
 
'''EXAMPLES'''
 
'''EXAMPLES'''

Revision as of 13:43, 31 January 2009

NAME

ns_proxy - Set connection to streaming state for streaming content via ns_write

SYNOPSIS

ns_proxy option ?arg arg ...?

DESCRIPTION

This command provides a simple, robust proxy mechanism to evaluate Tcl scripts in a separate, pipe-connected process. This approach can be useful both to isolate potentially thread-unsafe code outside the address space of a aolserver or to enable separation and timeout of potentially misbehaving, long running scripts. The proxy includes core Tcl commands as well as AOLserver commands from the libnsd library. Evaluating scripts in a proxy process can be used to isolate and/or timeout thread-unsafe or otherwise unsafe 3rd party code.
The legal options are:
  • ns_proxy get poolname ? -handles value? ? -timeout value?
Returns one or more handles to proxies from the specified pool. The pool will be created with default options if it does not already exist. The option -handle can be used to specify the number of handles allocated (default: 1). The option timeout specifies the maximum amount of time in milliseconds to wait for the handles to become available before raising an error. Requesting more than one handle in a single call (if more than one handle is required) is necessary as it is an error to request handles from a pool from which handles are already owned by the thread. This restriction is implemented to avoid possible deadlock conditions. The handle returned by this command can be used as a scalar value for other ns_proxy commands, or it can be used as Tcl command itself (see ns_proxy eval for more information).
  • ns_proxy release handle
Release a single handle. All handles owned by a thread must be returned before any handles can be allocated again.
  • ns_proxy eval handle script ?timeout?
Evalutes script in the proxy specified by handle. The optional timeout argument specifies a maximum number of milliseconds to wait for the command to complete before raising an error.
  • ns_proxy cleanup
Releases any handles from any pools currently owned by a thread. This command is intended to be used as part of a garbage collection step.
  • ns_proxy config poolname ? -init script? ? -reinit script? ? -min value? ? -max value? ? -exec program? ? -gettimeout value? ? -evaltimeout value? ? -sendtimeout value? ? -recvtimeout value? ? -waittimeout value?
Configure the specified pool. init can be used to specify a script to be evaluated, when the proxy (slave) is started. reinit specifies the script to be evaluated when the slave is re-initialized. min and max are the minimum and maximum number of slaves. exec names the program to be executed (defaults to nsproxy). gettimeout specifies the maximum time in ms to wait to allocate handles from the pool (default 5000). evaltimeout specifies the maximum time in ms to wait for a script to be evaluated in a proxy. This parameter can be overridden on a per-call basis with the optional timeout parameter to ns_proxy eval. The default is 0 milliseconds i.e. infinite. sendtimeout and recvtimeout' specify the maximum time to wait to send a script and receive a result from a proxy. waittimeout specifies the maximum time to wait for a proxy to exit.
  • ns_proxy ping handle
Check if handle is alive by sending an empty request.
  • ns_proxy active pool
Returns a list of all currently evaluating scripts in proxies for the given pool. The output is a list which includes two elements, the string name of the proxy handle and the string for the script being executed. It is also possible to view the currently evaluating scripts with the Unix ps command as the proxy slave process re-writes it's command argument space with the request script before evaluation and clears it after sending the result.
  • ns_proxy send handle script
Sends script in the proxy specified by handle. Unlike with ns_proxy eval, this option will return immediately while the script continues to execute in the proxy process. A later ns_proxy wait followed by an ns_proxy recv is expected.
  • ns_proxy wait handle ?timeout?
Waits for a script sent via ns_proxy send in the proxy specified by the handle argument to complete. The optional timeout parameter specifies the number of milliseconds to wait for the script to complete, the default is an indefinite wait.
  • ns_proxy recv
Receives a response from a script that was sent via ns_proxy send and waited on via ns_proxy wait.

EXAMPLES

ns_proxy get default

SEE ALSO

ns_limits