view MoinMoin/server/ @ 3105:80e1a910a2f1

make logging more configurable and flexible, packages/modules shall call MoinMoin.server.getLogger
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 23 Feb 2008 21:43:47 +0100
parents 806cf4814612
children c6e39279f83b
line wrap: on
line source
# -*- coding: iso-8859-1 -*-

    This is not really a server, it is just so that fastcgi stuff
    (the real server is likely Apache2) fits the model we have for
    Twisted and standalone server.

    Minimal usage:

        from MoinMoin.server.server_fastcgi import FastCgiConfig, run
        class Config(FastCgiConfig):

    See more options in FastCgiConfig class.

    @copyright: 2007 MoinMoin:ThomasWaldmann

    @license: GNU GPL, see COPYING for details.

import logging

from MoinMoin.server import Config
from MoinMoin.request import request_fcgi
from import thfcgi

# Set threads flag, so other code can use proper locking.
from MoinMoin import config
config.use_threads = 1
del config

class FastCgiConfig(Config):
    """ Set up default server """
    properties = {}
    # properties = {'script_name': '/'}

    # how many requests shall be handled by a moin fcgi process before it dies,
    # -1 mean "unlimited lifetime":
    max_requests = -1

    # how many threads to use (1 means use only main program, non-threaded)
    max_threads = 5

    # backlog, use in socket.listen(backlog) call
    backlog = 5

def run(ConfigClass=FastCgiConfig):
    config = ConfigClass()

    handle_request = lambda req, env, form, \
                         request_fcgi.Request(req, env, form, properties=properties).run()
    fcg = thfcgi.FCGI(handle_request, max_requests=config.max_requests, backlog=config.backlog, max_threads=config.max_threads)