2017-05-24 08:42:23 -05:00
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2016-12-02 02:10:41 -06:00
|
|
|
from ipaplatform.paths import paths
|
2011-11-22 07:39:23 -06:00
|
|
|
from ipalib import api
|
|
|
|
|
2017-05-24 08:42:23 -05:00
|
|
|
logger = logging.getLogger(os.path.basename(__file__))
|
|
|
|
|
2016-10-04 07:50:09 -05:00
|
|
|
api.bootstrap(context='server', confdir=paths.ETC_IPA, log=None) (ref:wsgi-app-bootstrap)
|
2011-11-22 07:39:23 -06:00
|
|
|
try:
|
|
|
|
api.finalize() (ref:wsgi-app-finalize)
|
2016-01-08 11:23:35 -06:00
|
|
|
except Exception as e:
|
2017-05-24 08:42:23 -05:00
|
|
|
logger.error('Failed to start IPA: %s', e)
|
2011-11-22 07:39:23 -06:00
|
|
|
else:
|
2017-05-24 08:42:23 -05:00
|
|
|
logger.info('*** PROCESS START ***')
|
2011-11-22 07:39:23 -06:00
|
|
|
|
|
|
|
# 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:
|
2017-05-24 08:42:23 -05:00
|
|
|
logger.error("IPA does not work with the threaded MPM, "
|
|
|
|
"use the pre-fork MPM") (ref:wsgi-app-end)
|