Remark: This connector does not allow requests to be multiplexed
(and let it know to the web server via FCGI_MPXS_CONNS=0).
Multiplexing requests is seldom done by
FastCGI modules and is even sometimes
impossible because of bugs in them. Moreover, multiplexing is
mostly useful if concurrent requests are handled by different
threads while this library use a single thread to process all
requests coming on a given connection. If the need is felt (speak
out!), a multithreaded connector can be built on the side of this
Netcgi.cgiclass with FCGI specific methods.
val run :
?allow:(Unix.sockaddr -> bool) ->
?sockaddr:Unix.sockaddr -> ?port:int -> (cgi -> unit) -> unit
run fregister the function
fas a main function of the script. Each call to the script will execute
f cgi. The code outside
fwill be executed only once (when the script is loaded into memory) which allows to cache database connections, etc.
allow: Tells whether a connection from the socket is allowed. Default: Use the comma separated list given in the environment variable FCGI_WEB_SERVER_ADDRS or allow all if it does not exist.
`Automaticfor all arguments.
Netcgi.exn_handler. Default: delegate all exceptions to the default handler.
sockaddr: tells on what socket to contact the script. If not specified, the script expects to be launched by the web server and to communicate with it through stdin. For external scripts (launched independently of the web server and possibly on a different machine), set
sockaddrto the address the web server needs to connect to to talk to the script (this address must also be specified in the wen server config file).
port: alternative way to specify
sockaddrlistening to localhost only. If you would like your FastCGI program to be accessed from a different machine, use
Your application should be ready handle SIGUSR1, used to resquest a "graceful" process shutdown, and SIGTERM to request a quick shutdown.
val handle_request :
(cgi -> unit) ->
log:(string -> unit) option -> Unix.file_descr -> Netcgi.connection_directive
handle_request config output_type arg_store eh f ~max_conns ~log fd: This is a lower-level interface that processes exactly one request arriving on the existing connection
max_conns is passed to the FCGI client and indicates how many
connections this server can process in parallel.
log is the error logger function or
None, in which case
errors are passed through to the FCGI client.
The other arguments are just like for
The return value indicates whether the connection can be kept
open or must be closed.