summaryrefslogtreecommitdiffstats
path: root/doc/guide/wsgi.py.txt
blob: 2b66001e4b5772c59aa5569bfb033ac63b722573 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import logging
import os

from ipaplatform.paths import paths
from ipalib import api

logger = logging.getLogger(os.path.basename(__file__))

api.bootstrap(context='server', confdir=paths.ETC_IPA, log=None) (ref:wsgi-app-bootstrap)
try:
    api.finalize() (ref:wsgi-app-finalize)
except Exception as e:
    logger.error('Failed to start IPA: %s', e)
else:
    logger.info('*** PROCESS START ***')

    # This is the WSGI callable:
    def application(environ, start_response): (ref:wsgi-app-start)
        if not environ['wsgi.multithread']:
            return api.Backend.session(environ, start_response)
        else:
            logger.error("IPA does not work with the threaded MPM, "
                         "use the pre-fork MPM") (ref:wsgi-app-end)