diff options
| -rw-r--r-- | src/mailman/rest/gunicorn.py | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/mailman/rest/gunicorn.py b/src/mailman/rest/gunicorn.py index 79e4ac504..489828715 100644 --- a/src/mailman/rest/gunicorn.py +++ b/src/mailman/rest/gunicorn.py @@ -1,4 +1,4 @@ -# Copyright (C) 2015 by the Free Software Foundation, Inc. +# Copyright (C) 2015-2017 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -20,7 +20,7 @@ To use this do the following: * Install gunicorn as a Python 3 application (in a venv if necessary). -* Create a mailman.cfg with at least the following it it: +* Create a mailman.cfg with at least the following in it: [runner.rest] start: no @@ -28,25 +28,33 @@ To use this do the following: * Start Mailman as normal: `mailman start` * Set the MAILMAN_CONFIG_FILE environment variable to the location of your mailman.cfg file from above. -* Run: gunicorn mailman.rest.gunicorn:make_application +* Run: gunicorn mailman.rest.gunicorn:run """ -__all__ = [ - 'make_application', - ] +from public import public -# Initializing the Mailman system once. -from mailman.core.initialize import initialize -initialize() -from mailman.rest.wsgiapp import make_application as base_application -app = base_application() +_initialized = False -def make_application(environ, start_response): + +@public +def run(environ, start_response): """Create the WSGI application. Use this if you want to integrate Mailman's REST server with an external WSGI server, such as gunicorn. Be sure to set the $MAILMAN_CONFIG_FILE environment variable. """ + # Imports are here to evaluate them lazily, prevent circular imports, and + # make flake8 happy. + global _initialized + if not _initialized: + from mailman.core.initialize import initialize + # First things first, initialize the system before any other imports or + # other operations. It must only be initialized once though. + initialize(propagate_logs=True) + _initialized = True + # Hook things up to WSGI. + from mailman.rest.wsgiapp import make_application + app = make_application() return app(environ, start_response) |
