# HG changeset patch # User jbe # Date 1503263536 -7200 # Node ID ac5f7a40b8c4a5f9c5a40a681260143d127f96e0 # Parent 83b3882dc31be6213a4b1804eab048c9516e5190 Extended documentation (mostly on "Configuration, pre-fork and post-fork initializers") diff -r 83b3882dc31b -r ac5f7a40b8c4 doc/autodoc-footer.htmlpart --- a/doc/autodoc-footer.htmlpart Wed Aug 16 00:31:11 2017 +0200 +++ b/doc/autodoc-footer.htmlpart Sun Aug 20 23:12:16 2017 +0200 @@ -1,7 +1,7 @@

- Copyright (c) 2009-2016 Public Software Group e. V., Berlin + Copyright (c) 2009-2017 Public Software Group e. V., Berlin

diff -r 83b3882dc31b -r ac5f7a40b8c4 doc/autodoc-header.htmlpart --- a/doc/autodoc-header.htmlpart Wed Aug 16 00:31:11 2017 +0200 +++ b/doc/autodoc-header.htmlpart Sun Aug 20 23:12:16 2017 +0200 @@ -43,7 +43,7 @@ margin-bottom: 0.3ex; } p { - margin: 0px; + margin-bottom: 1ex; line-height: 130%; } tt, pre { @@ -63,7 +63,7 @@ .autodoc_entry .short_synopsis { cursor: pointer; } - .autodoc_details { + .AUTODOC_details { padding-left: 1em; padding-right: 1em; border: 1px solid #777; @@ -95,11 +95,39 @@

Installation

- After downloading the tar.gz package, unpack it, enter the unpacked directory and type make. If you use Mac OS X or if you experience problems during compilation, you need to edit the Makefile.options file prior to compilation. The framework itself will be available in the framework/ directory, while a demo application is available in the demo-app/ directory. The framework.precompiled/ and demo-app.precompiled/ directories will contain a version with all Lua files being byte-code pre-compiled, which can be used instead. You may copy these directories (with cp -L to follow links) to any other place you like. Don't forget to setup a database, and make the tmp/ directory of the application writable for the web server process. Good luck and have fun! + After downloading the tar.gz package, unpack it, enter the unpacked directory and type make. If you use Mac OS X or if you experience problems during compilation, you need to edit the Makefile.options file prior to compilation. The framework itself will be available in the framework/ directory, while a demo application is available in the demo-app/ directory. The framework.precompiled/ and demo-app.precompiled/ directories will contain a version with all Lua files being byte-code pre-compiled, which can be used instead. You may copy these directories (with cp -L to follow links) to any other place you like. Don't forget to setup a database, and make the tmp/ directory of the application writable for user who executes WebMCP. Good luck and have fun! +

+

Configuration, initializers, and request handling

+

+ WebMCP uses the Moonbridge Network Server to handle HTTP requests. The Moonbridge Network Server listens to a TCP port and passes control to WebMCP by calling request.handler(...) for each request. However, before each request is processed, WebMCP will initialize the environment. This initialization includes tasks such as +

+ +

+ For each request, it is also possible to execute filters. Filters can be used to

-

Configuration, pre-fork and post-fork initializers

+

- The Moonbridge Network Server creates forks (i.e. clones) of the application server process in order to handle concurrent requests. Certain initializations may be performed before forking, other initializations must be performed after forking. 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. Execution order is as follows: + Filters and initializers are created by adding files in the application's directory structure. The filename determins 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 a command execute.inner(). The part before that command is executed before the request, and the part after that command is executed after the request. +

+

+ 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):

  1. @@ -151,7 +179,7 @@ { proto = "tcp", host = "::", port = 8080 }, { proto = "tcp", host = "0.0.0.0", port = 8080 } } -execute.inner() -- if done in pre-fork initializer +execute.inner() -- only use this line if done in pre-fork initializer

    Using the atom library

    Lua itself has only very few built-in data types. The atom library gives support for extra data types. Currently the following extra data types are provided: