webmcp

changeset 526:fe9932334bae

Revised section "Configuration, initializers, and request handling" in WebMCP documentation
author jbe
date Tue Aug 22 04:32:49 2017 +0200 (2017-08-22)
parents 8c9bcfc22faa
children c8e77723f9cf
files doc/autodoc-header.htmlpart
line diff
     1.1 --- a/doc/autodoc-header.htmlpart	Tue Aug 22 03:26:51 2017 +0200
     1.2 +++ b/doc/autodoc-header.htmlpart	Tue Aug 22 04:32:49 2017 +0200
     1.3 @@ -110,7 +110,13 @@
     1.4      </ol>
     1.5      <h2>Configuration, initializers, and request handling</h2>
     1.6      <p>
     1.7 -      WebMCP uses the <a href="http://www.public-software-group.org/moonbridge">Moonbridge Network Server</a> to handle HTTP requests. The Moonbridge Network Server listens to a TCP port and passes control to WebMCP by calling <a href="#request.handler"><tt>request.handler(...)</tt></a> for each request. However, before any request is processed, WebMCP will initialize the environment. This initialization includes tasks such as
     1.8 +      A WebMCP application may consist of several (sub-)applications. Each application sharing the same base directory also shares the database models but may provide different views and actions. The views and actions of an application are found within the "<tt>app/</tt><i>application_name</i><tt>/</tt>" directory, relative to the application base path. When starting WebMCP, the application's base path as well as the desired application name must be provided.
     1.9 +    </p>
    1.10 +    <p>
    1.11 +      In addition to selection of an application, a config file must be chosen when starting the application. This enables to run an application in different contexts, e.g. you may have one configuration file for development purposes and one for productive use. Configuration files are found in the "<tt>config/</tt>" directory, relative to the application base path.
    1.12 +    </p>
    1.13 +    <p>
    1.14 +      WebMCP uses the <a href="http://www.public-software-group.org/moonbridge">Moonbridge Network Server</a> to handle HTTP requests. The Moonbridge Network Server listens to a TCP port and passes control to WebMCP (by invoking <tt>bin/mcp.lua</tt> in the framework's base directory), eventually resulting in a call of <a href="#request.handler"><tt>request.handler(...)</tt></a> for each request. However, before any request is processed, WebMCP will initialize the environment. This initialization includes tasks such as
    1.15      </p>
    1.16      <ul>
    1.17        <li>loading libraries,</li>
    1.18 @@ -135,7 +141,10 @@
    1.19        </li>
    1.20      </ul>
    1.21      <p>
    1.22 -      Filters and initializers are created by adding files in the application's directory structure. The filename determines the execution order of otherwise equally ranked initializers and/or filters. It is a common idiom to start the filename of a filter or initializer with a two digit number to be easily able to change the execution order when desired. Filters and initializers are executed both before and after a request. Each file must contain an <a href="#execute.inner"><tt>execute.inner()</tt></a> command. The part before that command is executed before the request, and the part after that command is executed after the request.
    1.23 +      Filters and initializers are created by adding files in the application's directory structure. The filename determines the execution order (lexicographical order). It is a common idiom to start the filename of a filter or initializer with a two digit number to be easily able to change the execution order when desired. Filters and initializers are wrapping requests, i.e. part of them is executed before and part after the remaining request handling.
    1.24 +    </p>
    1.25 +    <p>
    1.26 +      When an initializer or filter calls <a href="#execute.inner"><tt>execute.inner()</tt></a>, execution of the initializer or filter is suspended and the remaining initializers and/or filters or the requested view or action are executed. Afterwards, the interrupted filters and initializers are resumed in reverse order (from where they called <tt>execute.inner()</tt>). Most often, <tt>execute.inner()</tt> is the last line in an initializer or filter, resulting in all code to be executed prior to request handling (and nothing to be executed afterwards).
    1.27      </p>
    1.28      <p>
    1.29        The Moonbridge server creates forks (i.e. clones) of the application server process (i.e. the whole Lua engine including all libraries and variables) in order to handle concurrent requests. Certain initializations may be performed before forking, other initializations must be performed after forking. For this purpose, WebMCP allows an application to provide so-called "pre-fork" and "post-fork" initializers. The application's configuration files as well as its pre-fork initializers are executed before forking. The application's post-fork initializers are executed after forking. In particular, any libraries that open file or network handles during initialization must not be loaded before the server process is forked. Opening database connections must be performed after forking as well. WebMCP follows the following execution order (directory structure is explained further down):

Impressum / About Us