From adc722359d7c5ca44c0718ef3d91f14da174cd32 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sun, 8 Dec 2013 19:15:06 +0100 Subject: [PATCH] move application export to isso.run When using Gunicorn or uWSGI to run `isso.dispatch` it would automatically initialize and a default Isso instance (and cause several logging messages), although never used. If you use uWSGI or Gunicorn, you have to change the module from `isso` to `isso.run`. --- docs/docs/extras/uwsgi.rst | 2 +- docs/docs/quickstart.rst | 2 +- isso/__init__.py | 4 ---- isso/run.py | 8 ++++++++ 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 isso/run.py diff --git a/docs/docs/extras/uwsgi.rst b/docs/docs/extras/uwsgi.rst index 018a86d..9569e62 100644 --- a/docs/docs/extras/uwsgi.rst +++ b/docs/docs/extras/uwsgi.rst @@ -36,7 +36,7 @@ supply everything as command-line arguments): processes = 4 cache2 = name=hash,items=1024,blocksize=32 spooler = %d/mail - module = isso + module = isso.run virtualenv = %d env = ISSO_SETTINGS=%d/sample.cfg diff --git a/docs/docs/quickstart.rst b/docs/docs/quickstart.rst index 4defe85..fb5ac14 100644 --- a/docs/docs/quickstart.rst +++ b/docs/docs/quickstart.rst @@ -184,4 +184,4 @@ To execute Isso, use a command similar to: .. code-block:: sh $ export ISSO_SETTINGS="/path/to/isso.cfg" - $ gunicorn -b localhost:8080 -w 4 --preload isso + $ gunicorn -b localhost:8080 -w 4 --preload isso.run diff --git a/isso/__init__.py b/isso/__init__.py index d527b33..d668f3e 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -223,7 +223,3 @@ def main(): if ex.errno != errno.ENOENT: raise wsgi.SocketHTTPServer(sock, make_app(conf)).serve_forever() - - -if sys.argv[0].endswith(("uwsgi", "gunicorn")): - application = make_app(Config.load(os.environ.get('ISSO_SETTINGS'))) diff --git a/isso/run.py b/isso/run.py new file mode 100644 index 0000000..0a156e9 --- /dev/null +++ b/isso/run.py @@ -0,0 +1,8 @@ +# -*- encoding: utf-8 -*- + +import os + +from isso import make_app +from isso.core import Config + +application = make_app(Config.load(os.environ.get('ISSO_SETTINGS')))