1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type">
<link rel="Start" href="index.html">
<link rel="previous" href="Netcgi_jserv_ajp12.html">
<link rel="next" href="Netcgi_fcgi_10.html">
<link rel="Up" href="index.html">
<link title="Index of types" rel=Appendix href="index_types.html">
<link title="Index of exceptions" rel=Appendix href="index_exceptions.html">
<link title="Index of values" rel=Appendix href="index_values.html">
<link title="Index of class methods" rel=Appendix href="index_methods.html">
<link title="Index of classes" rel=Appendix href="index_classes.html">
<link title="Index of class types" rel=Appendix href="index_class_types.html">
<link title="Index of modules" rel=Appendix href="index_modules.html">
<link title="Netcgi_env" rel="Chapter" href="Netcgi_env.html">
<link title="Netcgi_types" rel="Chapter" href="Netcgi_types.html">
<link title="Netcgi" rel="Chapter" href="Netcgi.html">
<link title="Netcgi_jserv" rel="Chapter" href="Netcgi_jserv.html">
<link title="Netcgi_jserv_ajp12" rel="Chapter" href="Netcgi_jserv_ajp12.html">
<link title="Netcgi_jserv_app" rel="Chapter" href="Netcgi_jserv_app.html">
<link title="Netcgi_fcgi_10" rel="Chapter" href="Netcgi_fcgi_10.html">
<link title="Netcgi_fcgi" rel="Chapter" href="Netcgi_fcgi.html">
<link title="Netcgi1_compat" rel="Chapter" href="Netcgi1_compat.html"><title>Ocamlnet 2 Reference Manual (netcgi1 add-on) : Netcgi_jserv_app</title>
</head>
<body>
<div class="navbar"><a href="Netcgi_jserv_ajp12.html">Previous</a>
<a href="index.html">Up</a>
<a href="Netcgi_fcgi_10.html">Next</a>
</div>
<center><h1>Module <a href="type_Netcgi_jserv_app.html">Netcgi_jserv_app</a></h1></center>
<br>
<pre><span class="keyword">module</span> Netcgi_jserv_app: <code class="code">sig</code> <a href="Netcgi_jserv_app.html">..</a> <code class="code">end</code></pre>AJP-based Application Servers<br>
<hr width="100%">
<br>
This module contains a "ready to use" application server framework
for single-threaded and multi-process servers.<br>
<br><code><span class="keyword">type</span> <a name="TYPErequest_handler"></a><code class="type"></code>request_handler = {</code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>req_activate : <code class="type"><a href="Netcgi_types.cgi_activation.html">Netcgi_types.cgi_activation</a> -> unit</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>req_processing : <code class="type">string -> Netmime.mime_header -> <a href="Netcgi.html#TYPEargument_processing">Netcgi.argument_processing</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>req_operating_type : <code class="type"><a href="Netcgi.html#TYPEoperating_type">Netcgi.operating_type</a></code>;</code></td>
</tr></table>
}
<div class="info">
The request handler consists of:<ul>
<li><code class="code">req_activate</code>: A function to process requests and to generate
responses. The function gets a fully initialized <code class="code">cgi_activation</code>
object, and is expected to write the response.</li>
<li><code class="code">req_processing</code>: Style of CGI argument processing. Same meaning as in
<a href="Netcgi.html"><code class="code">Netcgi</code></a>.</li>
<li><code class="code">req_operating_type</code>: Style of CGI response buffering. Same meaning as in
<a href="Netcgi.html"><code class="code">Netcgi</code></a>.</li>
</ul>
<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEserver_type"></a><code class="type"></code>server_type = <code class="type">[ `Forking of int * (string * <a href="Netcgi_jserv_app.html#TYPErequest_handler">request_handler</a>) list<br> | `Process_pool of int * (string * <a href="Netcgi_jserv_app.html#TYPErequest_handler">request_handler</a>) list<br> | `Sequential of (string * <a href="Netcgi_jserv_app.html#TYPErequest_handler">request_handler</a>) list ]</code> </pre>
<div class="info">
Server type:<ul>
<li><code class="code">`Sequential servlets</code>: The server processes the requests sequentially.</li>
<li><code class="code">`Forking(n,servlets)</code>: The server forks for every request, and processes it in the
child process. The integer <code class="code">n</code> is the maximum number of children
processes; if it is exceeded, an error message is displayed immediately
without forking.</li>
<li><code class="code">`Process_pool(n,servlets)</code>: The server forks a fixed number of times (the integer <code class="code">n</code>).
The children will process the requests concurrently. If more requests
arrive than children are available, the requests must wait until
a child becomes free again.</li>
</ul>
In <code class="code">servlets</code> the list of available servlets is passed. The strings
are the names of the servlets (part of the URL), and the <code class="code">request_handlers</code>s
are the corresponding handlers.<br>
</div>
<pre><span class="keyword">type</span> <a name="TYPEprotocol_type"></a><code class="type"></code>protocol_type = <code class="type">[ `Ajp_1_2 ]</code> </pre>
<div class="info">
Selects the protocol.<br>
</div>
<br><code><span class="keyword">type</span> <a name="TYPEjserv_config"></a><code class="type"></code>jserv_config = {</code><table class="typetable">
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_backlog : <code class="type">int</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_reuseaddr : <code class="type">bool</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_cgiconfig : <code class="type"><a href="Netcgi_env.html#TYPEcgi_config">Netcgi_env.cgi_config</a></code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_init_process : <code class="type">unit -> unit</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_fini_process : <code class="type">unit -> unit</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_idle_worker : <code class="type">unit -> unit</code>;</code></td>
</tr>
<tr>
<td align="left" valign="top" >
<code> </code></td>
<td align="left" valign="top" >
<code>js_idle_master : <code class="type">unit -> unit</code>;</code></td>
</tr></table>
}
<div class="info">
Server configuration:<ul>
<li><code class="code">js_backlog</code> is the maximum length of the backlog queue (containing
client connections that are not yet accepted by the application
server)</li>
<li><code class="code">js_reuseaddr</code>: Whether to reuse the port immediately</li>
<li><code class="code">js_cgiconfig</code>: The CGI-level configuration</li>
<li><code class="code">js_init_process</code>: This hook is called when a new process is
initialized. For <code class="code">`Sequential</code> servers it is called once before
the server begins to accept connections. For <code class="code">`Forking</code> and
<code class="code">`Process_pool</code> servers it is called when new processes are
forking.</li>
<li><code class="code">js_fini_process</code>: The reverse hook of <code class="code">js_init_process</code>: Called
after a process receives the shutdown notification.
For <code class="code">`Sequential</code> servers it is called once after
the server stops to accept connections. For <code class="code">`Forking</code> and
<code class="code">`Process_pool</code> servers it is called before sub processes exit.</li>
<li><code class="code">js_idle_master</code>: This hook is called every second by the
master process that accepts new connections. When it raises
an exception, the master socket is closed, and the exception
falls through to the caller.</li>
<li><code class="code">js_idle_worker</code>: This hook is called every second by the
worker process that processes connections. Exceptions are logged.</li>
</ul>
Examples:<ul>
<li><code class="code">js_init_process</code>: Open a new database connection for every process</li>
<li><code class="code">js_fini_process</code>: Close the database connection</li>
<li><code class="code">js_idle_master</code>: Check whether the server should shut down, and
if so, raise an exception to exit</li>
<li><code class="code">js_idle_worker</code>: Close database connections after a period
of inactivity</li>
</ul>
<br>
</div>
<pre><span class="keyword">val</span> <a name="VALstd_config"></a>std_config : <code class="type"><a href="Netcgi_jserv_app.html#TYPEjserv_config">jserv_config</a></code></pre><div class="info">
The standard configuration:
<p>
<ul>
<li>small backlog</li>
<li>ports are reused</li>
<li>default CGI configuration</li>
<li>callback functions are all (fun () -> ()).</li>
</ul>
<br>
</div>
<pre><span class="keyword">val</span> <a name="VALlogger"></a>logger : <code class="type">(string -> string -> unit) Pervasives.ref</code></pre><div class="info">
This variable contains the logger function. The function is called to
log error conditions. The first passed string is the servlet name,
or "?" if not available. The second passed string is the message.
By default, the messages are written to stderr.<br>
</div>
<pre><span class="keyword">val</span> <a name="VALrun"></a>run : <code class="type">?config:<a href="Netcgi_jserv_app.html#TYPEjserv_config">jserv_config</a> -><br> <a href="Netcgi_jserv_app.html#TYPEserver_type">server_type</a> -><br> <a href="Netcgi_jserv_app.html#TYPEprotocol_type">protocol_type</a> -><br> (string * string) list -><br> <a href="Netcgi_jserv.html#TYPEauth">Netcgi_jserv.auth</a> option -> Unix.inet_addr -> int -> unit</code></pre><div class="info">
Starts the server. The last four arguments are compatible with the
function accepted by <a href="Netcgi_jserv.html#VALjvm_emu_main"><code class="code">Netcgi_jserv.jvm_emu_main</code></a>, so <code class="code">run</code> can be
used as follows:
<p>
<pre><code class="code"> Netcgi_jserv.jvm_emu_main (run ~config srvtype prttype) </code></pre>
<p>
The server runs until it gets a shutdown notification from Apache.
<p>
Restart notifications are currently ignored.
<p>
Another remark about <code class="code">`Process_pool</code>. The signal handler for SIGALRM
is temporarily redefined while a process waits for a lock. The old
handler is suspended until the lock can be acquired.<br>
</div>
</body></html>
|