1 # Copyright (C) 2015-2018 by the Free Software Foundation, Inc.
3 # This file is part of GNU Mailman.
5 # GNU Mailman is free software: you can redistribute it and/or modify it under
6 # the terms of the GNU General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option)
10 # GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 # You should have received a copy of the GNU General Public License along with
16 # GNU Mailman. If not, see <https://www.gnu.org/licenses/>.
18 """Experimental Gunicorn based REST server.
20 To use this do the following:
22 * Install gunicorn as a Python 3 application (in a venv if necessary).
23 * Copy this file into your Python's site-packages under the name mmgunicorn.py
24 * Create a mailman.cfg with at least the following in it:
29 * Start Mailman as normal: `mailman start`
30 * Set the MAILMAN_CONFIG_FILE environment variable to the location of your
31 mailman.cfg file from above.
32 * Run: gunicorn mmgunicorn:run
35 from public
import public
42 def run(environ
, start_response
):
43 """Create the WSGI application.
45 Use this if you want to integrate Mailman's REST server with an external
46 WSGI server, such as gunicorn. Be sure to set the $MAILMAN_CONFIG_FILE
49 # Imports are here to evaluate them lazily, prevent circular imports, and
53 from mailman
.core
.initialize
import initialize
55 # First things first, initialize the system before any other imports or
56 # other operations. It must only be initialized once though.
57 initialize(propagate_logs
=True)
59 # Hook things up to WSGI.
60 from mailman
.rest
.wsgiapp
import make_application
61 app
= make_application()
62 return app(environ
, start_response
)