From 9e0d04b56215d18f6ee40149d75d042c71a06fed Mon Sep 17 00:00:00 2001 From: Yue Du Date: Tue, 13 May 2014 10:37:56 +0800 Subject: [PATCH 01/20] Fix: logger_class can be undefined. --- gunicorn/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index c41ecd16..a739deb4 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -123,10 +123,10 @@ class Config(object): if uri == "simple": # support the default uri = "gunicorn.glogging.Logger" - else: - logger_class = util.load_class(uri, - default="gunicorn.glogging.Logger", - section="gunicorn.loggers") + + logger_class = util.load_class(uri, + default="gunicorn.glogging.Logger", + section="gunicorn.loggers") if hasattr(logger_class, "install"): logger_class.install() From 63967597a059910adf0480717246cb0a18a7fcdc Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Tue, 13 May 2014 11:07:52 -0700 Subject: [PATCH 02/20] Fix mixed up worker signal handling Commit 81241907ffcf94517ffa14b8427205906b61b540 changed the signal handling by switching the roles of `TERM` and `QUIT` for the arbiter so that `TERM` is graceful and `QUIT` is not. At the time, workers performed graceful shutdown on `QUIT` and quick shutdown on `TERM` and `INT`. This behavior was also changed so that `QUIT` (and `INT`) cause a quick shutdown and `TERM` is graceful. However, the documentation incorrectly reversed the roles of the worker signals and the arbiter was not updated to use the correct signals. This commit fixes the documentation and the arbiter signals. --- docs/source/signals.rst | 4 ++-- gunicorn/arbiter.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/source/signals.rst b/docs/source/signals.rst index d4fd4fc2..c37a34f3 100644 --- a/docs/source/signals.rst +++ b/docs/source/signals.rst @@ -35,8 +35,8 @@ Sending signals directly to the worker processes should not normally be needed. If the master process is running, any exited worker will be automatically respawned. -- **QUIT**, **INT**: Graceful shutdown -- **TERM**: Quick shutdown +- **QUIT**, **INT**: Quick shutdown +- **TERM**: Graceful shutdown - **USR1**: Reopen the log files Reload the configuration diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 982b5312..8de36d09 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -336,9 +336,9 @@ class Arbiter(object): killed gracefully (ie. trying to wait for the current connection) """ self.LISTENERS = [] - sig = signal.SIGQUIT + sig = signal.SIGTERM if not graceful: - sig = signal.SIGTERM + sig = signal.SIGQUIT limit = time.time() + self.cfg.graceful_timeout while self.WORKERS and time.time() < limit: self.kill_workers(sig) From 9c1b46f9983809a4b4df03731cc261d4ce682128 Mon Sep 17 00:00:00 2001 From: Nick Pillitteri Date: Sat, 10 May 2014 21:47:55 -0400 Subject: [PATCH 03/20] Move setting of environmental variables before preload_app start. Move setting of env vars from Arbiter.start to Arbiter.setup so that they are available during application start up when 'preload_app' is used. Closes #735 --- gunicorn/arbiter.py | 10 +++--- tests/test_008-arbiter-env.py | 57 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 tests/test_008-arbiter-env.py diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 982b5312..7c5a1e52 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -106,6 +106,11 @@ class Arbiter(object): in sorted(self.cfg.settings.items(), key=lambda setting: setting[1])))) + # set enviroment' variables + if self.cfg.env: + for k, v in self.cfg.env.items(): + os.environ[k] = v + if self.cfg.preload_app: self.app.wsgi() @@ -121,11 +126,6 @@ class Arbiter(object): self.pidfile.create(self.pid) self.cfg.on_starting(self) - # set enviroment' variables - if self.cfg.env: - for k, v in self.cfg.env.items(): - os.environ[k] = v - self.init_signals() if not self.LISTENERS: self.LISTENERS = create_sockets(self.cfg, self.log) diff --git a/tests/test_008-arbiter-env.py b/tests/test_008-arbiter-env.py new file mode 100644 index 00000000..880824d4 --- /dev/null +++ b/tests/test_008-arbiter-env.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 - +# +# This file is part of gunicorn released under the MIT license. +# See the NOTICE for more information. + +import t +import os +from gunicorn.app.base import BaseApplication +import gunicorn.arbiter + + +class PreloadedAppWithEnvSettings(BaseApplication): + """ + Simple application that makes use of the 'preload' feature to + start the application before spawning worker processes and sets + environmental variable configuration settings. + """ + + def init(self, parser, opts, args): + """No-op""" + pass + + def load(self): + """No-op""" + pass + + def load_config(self): + """Set the 'preload_app' and 'raw_env' settings in order to verify their + interaction below. + """ + self.cfg.set('raw_env', [ + 'SOME_PATH=/tmp/something', 'OTHER_PATH=/tmp/something/else']) + self.cfg.set('preload_app', True) + + def wsgi(self): + """Assert that the expected environmental variables are set when + the main entry point of this application is called as part of a + 'preloaded' application. + """ + verify_env_vars() + return super(PreloadedAppWithEnvSettings, self).wsgi() + + +def verify_env_vars(): + t.eq(os.getenv('SOME_PATH'), '/tmp/something') + t.eq(os.getenv('OTHER_PATH'), '/tmp/something/else') + + +def test_env_vars_available_during_preload(): + """Ensure that configured environmental variables are set during the + initial set up of the application (called from the .setup() method of + the Arbiter) such that they are available during the initial loading + of the WSGI application. + """ + # Note that we aren't making any assertions here, they are made in the + # dummy application object being loaded here instead. + gunicorn.arbiter.Arbiter(PreloadedAppWithEnvSettings()) From cb817dfa98c93d13d8656b29e7068ce50630275e Mon Sep 17 00:00:00 2001 From: Yue Du Date: Wed, 14 May 2014 14:08:18 +0800 Subject: [PATCH 04/20] Remove unused imports --- gunicorn/config.py | 1 - gunicorn/reloader.py | 1 - gunicorn/workers/base.py | 1 - 3 files changed, 3 deletions(-) diff --git a/gunicorn/config.py b/gunicorn/config.py index a739deb4..6cadd09b 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -15,7 +15,6 @@ import pwd import ssl import sys import textwrap -import types from gunicorn import __version__ from gunicorn.errors import ConfigError diff --git a/gunicorn/reloader.py b/gunicorn/reloader.py index 4333ef7f..219ffa83 100644 --- a/gunicorn/reloader.py +++ b/gunicorn/reloader.py @@ -5,7 +5,6 @@ import os import re -import signal import sys import time import threading diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index d2b07090..5be83efd 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -7,7 +7,6 @@ from datetime import datetime import os import signal import sys -import traceback from gunicorn import util From 9eb589576dba0044589fbbe550edb739fff8f5eb Mon Sep 17 00:00:00 2001 From: WooParadog Date: Wed, 14 May 2014 17:45:30 +0800 Subject: [PATCH 05/20] Stop all servers --- gunicorn/workers/ggevent.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index 167a0a54..c7c4dfba 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -121,10 +121,11 @@ class GeventWorker(AsyncWorker): except KeyboardInterrupt: pass except: - try: - server.stop() - except: - pass + for server in servers: + try: + server.stop() + except: + pass raise try: From 829e8d32d4f76f960158d865be80363e7cd918b7 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 15 May 2014 00:34:02 +0300 Subject: [PATCH 06/20] Remove __future__.with_statement imports. Gunicorn requires Python 2.6 or newer now: http://docs.gunicorn.org/en/latest/install.html#requirements --- gunicorn/arbiter.py | 2 -- gunicorn/pidfile.py | 2 -- gunicorn/workers/ggevent.py | 2 -- tests/t.py | 2 -- tests/test_003-config.py | 2 -- tests/treq.py | 2 -- 6 files changed, 12 deletions(-) diff --git a/gunicorn/arbiter.py b/gunicorn/arbiter.py index 458316e2..6f4587af 100644 --- a/gunicorn/arbiter.py +++ b/gunicorn/arbiter.py @@ -3,8 +3,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -from __future__ import with_statement - import errno import os import random diff --git a/gunicorn/pidfile.py b/gunicorn/pidfile.py index 32a9ac37..2309ba88 100644 --- a/gunicorn/pidfile.py +++ b/gunicorn/pidfile.py @@ -3,8 +3,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -from __future__ import with_statement - import errno import os import tempfile diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index c7c4dfba..9724011d 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -3,8 +3,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -from __future__ import with_statement - import errno import os import sys diff --git a/tests/t.py b/tests/t.py index 6f1d044a..c84dc671 100644 --- a/tests/t.py +++ b/tests/t.py @@ -4,8 +4,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -from __future__ import with_statement - import array import os import tempfile diff --git a/tests/test_003-config.py b/tests/test_003-config.py index 628e863a..c35feb79 100644 --- a/tests/test_003-config.py +++ b/tests/test_003-config.py @@ -3,8 +3,6 @@ # This file is part of gunicorn released under the MIT license. # See the NOTICE for more information. -from __future__ import with_statement - import t import functools diff --git a/tests/treq.py b/tests/treq.py index 10557b1e..816c31ec 100644 --- a/tests/treq.py +++ b/tests/treq.py @@ -3,8 +3,6 @@ # This file is part of the pywebmachine package released # under the MIT license. -from __future__ import with_statement - import t import inspect From 2f932664fd7cb482ce4b90d22de21a08b9a19d69 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 15 May 2014 00:53:47 +0300 Subject: [PATCH 07/20] Remove the redundant if clause in gunicorn/workers/workertmp.py. --- gunicorn/workers/workertmp.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gunicorn/workers/workertmp.py b/gunicorn/workers/workertmp.py index 3d6af9eb..36bc97a6 100644 --- a/gunicorn/workers/workertmp.py +++ b/gunicorn/workers/workertmp.py @@ -10,10 +10,8 @@ import tempfile from gunicorn import util PLATFORM = platform.system() -if PLATFORM.startswith('CYGWIN'): - IS_CYGWIN = True -else: - IS_CYGWIN = False +IS_CYGWIN = PLATFORM.startswith('CYGWIN') + class WorkerTmp(object): From 9f8f37d07d0e50439e3423855bc888b9129644e0 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 15 May 2014 01:16:38 +0300 Subject: [PATCH 08/20] Add Python 3.4 to classifiers. I tested Gunicorn with the following command on Pytohn 3.4.0: $ python3.4 -m venv venv34 $ . venv34/bin/activate $ pip install -e . $ pip install -r requirements_dev.txt $ py.test tests/ --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 050ab617..6b6e474e 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ CLASSIFIERS = [ 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.2', 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', 'Topic :: Internet', 'Topic :: Utilities', 'Topic :: Software Development :: Libraries :: Python Modules', From 08ec1b2c703648691468763728174f8fdc4e2d06 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 15 May 2014 01:19:49 +0300 Subject: [PATCH 09/20] Also, enable Python 3.4 on Travis CI. (The "--use-mirrors" option was deprecated, so I removed it.) --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c602bb2f..2dea0409 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,10 @@ python: - "2.6" - "2.7" - "3.3" + - "3.4" - "pypy" install: - - "pip install -r requirements_dev.txt --use-mirrors" + - "pip install -r requirements_dev.txt" - "python setup.py install" script: py.test -x tests/ branches: From be90882151e7c1f9b5617f815652da752b27ed39 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 15 May 2014 23:39:14 +0300 Subject: [PATCH 10/20] Cleanup Makefile. - The "--no-site-packages" option is default now - "pip install -e" is basically equivalent to "python setup.py develop" - Delete also dist/ and MANIFEST - Delete all *.py[co] files (and __pycache__ directories on Python 3) --- .gitignore | 9 +++------ Makefile | 16 ++++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 363dd99f..63230128 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ *.sw* *.pyc *#* +venv* +__pycache__ +MANIFEST build dist setuptools-* @@ -14,12 +17,6 @@ distribute-0.6.8.tar.gz gunicorn.egg-info nohup.out .coverage -doc/.sass-cache -bin/ -lib/ -man/ -include/ -html/ examples/frameworks/pylonstest/PasteScript* examples/frameworks/pylonstest/pylonstest.egg-info/ examples/frameworks/django/testing/testdb.sql diff --git a/Makefile b/Makefile index 43908092..d9b3622d 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,17 @@ build: - virtualenv --no-site-packages . - bin/python setup.py develop - bin/pip install -r requirements_dev.txt + virtualenv venv + venv/bin/pip install -e . + venv/bin/pip install -r requirements_dev.txt test: - bin/python setup.py test + venv/bin/python setup.py test coverage: - bin/python setup.py test --cov + venv/bin/python setup.py test --cov clean: - @rm -rf .Python bin lib include man build html + @rm -rf .Python MANIFEST build dist venv* *.egg-info + @find . -type f -name "*.py[co]" -delete + @find . -type d -name "__pycache__" -delete + +.PHONY: build clean coverage test From 109880a8c33373b086541f9ba85626096836f760 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sat, 17 May 2014 23:55:41 +0300 Subject: [PATCH 11/20] Update installation docs to mention about pip. Other changes: - Minor markup and style changes - Use https in URLs - Remove the "python setup.py develop" part from the documentation. It's useful for development. --- docs/source/install.rst | 104 +++++++++++++--------------------------- 1 file changed, 32 insertions(+), 72 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 7d284faf..0efcd72e 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -2,65 +2,34 @@ Installation ============ -Follow the following steps to install Gunicorn. +.. highlight:: bash -Requirements -============ +:Requirements: **Python 2.x >= 2.6** or **Python 3.x >= 3.1** -- **Python 2.x >= 2.6** or **Python 3.x >= 3.1** -- setuptools >= 0.6c6 -- nosetests (for the test suite only) +To install the latest released version of Gunicorn:: -With easy_install -================= - -If you don't already have ``easy_install`` available you'll want to download -and run the ``ez_setup.py`` script:: - - $ curl -O http://peak.telecommunity.com/dist/ez_setup.py - $ sudo python ez_setup.py -U setuptools - -To install or upgrade to the latest released version of Gunicorn:: - - $ sudo easy_install -U gunicorn + $ pip install gunicorn .. note:: There is a limited support version of Gunicorn that is compatible with Python 2.4. This fork is managed by Randall Leeds and can be - found `here on github`_. To install this version you must specify - the full url to something like ``pip``. This hasn't been tested - wtih ``easy_install`` just yet:: + found `here on GitHub`_. To install this version via ``pip``, you + must specify the *py24* branch:: - $ pip install -f http://github.com/tilgovi/gunicorn/tarball/py24 gunicorn + $ pip install git+https://github.com/tilgovi/gunicorn.git@py24 From Source =========== You can install Gunicorn from source just as you would install any other -Python package. Gunicorn uses setuptools which will automatically fetch all -dependencies (including setuptools itself). +Python package:: -You can download a tarball of the latest sources from `GitHub Downloads`_ or -fetch them with git_:: + $ pip install git+https://github.com/benoitc/gunicorn.git - # Using git: - $ git clone git://github.com/benoitc/gunicorn.git - $ cd gunicorn +This will allow you To keep up to date with development on GitHub:: - # Or using a tarball: - $ wget http://github.com/benoitc/gunicorn/tarball/master -o gunicorn.tar.gz - $ tar -xvzf gunicorn.tar.gz - $ cd gunicorn-$HASH/ + $ pip install -U git+https://github.com/benoitc/gunicorn.git - # Install - $ sudo python setup.py install - -If you've cloned the git repository, its highly recommended that you use the -``develop`` command which will allow you to use Gunicorn from the source -directory. This will allow you to keep up to date with development on GitHub as -well as make changes to the source:: - - $ python setup.py develop Async Workers ============= @@ -72,9 +41,9 @@ want to consider one of the alternate worker types. :: - $ easy_install -U greenlet # Required for both - $ easy_install -U eventlet # For eventlet workers - $ easy_install -U gevent # For gevent workers + $ pip install greenlet # Required for both + $ pip install eventlet # For eventlet workers + $ pip install gevent # For gevent workers .. note:: If installing ``greenlet`` fails you probably need to install @@ -87,6 +56,7 @@ want to consider one of the alternate worker types. package manager. If Gevent_ fails to build even with libevent_ installed, this is the most likely reason. + Debian GNU/Linux ================ @@ -95,22 +65,22 @@ system packages to install Gunicorn except maybe when you want to use different versions of gunicorn with virtualenv. This has a number of advantages: - * Zero-effort installation: Automatically starts multiple Gunicorn instances - based on configurations defined in ``/etc/gunicorn.d``. +* Zero-effort installation: Automatically starts multiple Gunicorn instances + based on configurations defined in ``/etc/gunicorn.d``. - * Sensible default locations for logs (``/var/log/gunicorn``). Logs - can be automatically rotated and compressed using ``logrotate``. +* Sensible default locations for logs (``/var/log/gunicorn``). Logs + can be automatically rotated and compressed using ``logrotate``. - * Improved security: Can easily run each Gunicorn instance with a dedicated - UNIX user/group. +* Improved security: Can easily run each Gunicorn instance with a dedicated + UNIX user/group. - * Sensible upgrade path: Upgrades to newer versions result in less downtime, - handle conflicting changes in configuration options, and can be quickly - rolled back in case of incompatibility. The package can also be purged - entirely from the system in seconds. +* Sensible upgrade path: Upgrades to newer versions result in less downtime, + handle conflicting changes in configuration options, and can be quickly + rolled back in case of incompatibility. The package can also be purged + entirely from the system in seconds. Stable ("wheezy") ------------------- +----------------- The version of Gunicorn in the Debian_ "stable" distribution is 0.14.5 (June 2012). You can install it using:: @@ -166,6 +136,8 @@ our PPA_ by adding ``ppa:gunicorn/ppa`` to your system's Software Sources. Use the ``apt-add-repository`` command from the ``python-software-properties`` package to add the Gunicorn software source. +:: + $ sudo apt-add-repository ppa:gunicorn/ppa Or this PPA can be added to your system manually by copying the lines below @@ -174,27 +146,15 @@ and adding them to your system's software sources:: deb http://ppa.launchpad.net/gunicorn/ppa/ubuntu lucid main deb-src http://ppa.launchpad.net/gunicorn/ppa/ubuntu lucid main -Replace 'lucid' with your Ubuntu distribution series. +Replace *lucid* with your Ubuntu distribution series. -Signing key ------------ +:Signing key: ``1024R/5370FF2A`` +:Fingerprint: ``FC7B41B54C9B8476D9EC22A2C6773E575370FF2A`` -:: - 1024R/5370FF2A - -Fingerprint ------------ - -:: - - FC7B41B54C9B8476D9EC22A2C6773E575370FF2A - -.. _`GitHub Downloads`: http://github.com/benoitc/gunicorn/downloads .. _`design docs`: design.html -.. _git: http://git-scm.com/ .. _Eventlet: http://eventlet.net -.. _`here on github`: http://github.com/tilgovi/gunicorn +.. _`here on GitHub`: http://github.com/tilgovi/gunicorn .. _Gevent: http://gevent.org .. _libevent: http://monkey.org/~provos/libevent .. _Debian: http://www.debian.org/ From dcaf2d7f9b1ddd3d629bbde3fb0f4989d3e6a95c Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 18 May 2014 01:01:35 +0300 Subject: [PATCH 12/20] Remove an outdated paragraph about getting CPU information. Python 2.5 or older versions are not supported by Gunicorn. Also, fixed a typo: mentionned -> mentioned --- docs/source/configure.rst | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/source/configure.rst b/docs/source/configure.rst index fa95f415..9f310293 100644 --- a/docs/source/configure.rst +++ b/docs/source/configure.rst @@ -64,17 +64,7 @@ For instance:: bind = "127.0.0.1:8000" workers = multiprocessing.cpu_count() * 2 + 1 -On a side note, Python's older than 2.6 can use sysconf to get the -number of processors:: - - import os - - def numCPUs(): - if not hasattr(os, "sysconf"): - raise RuntimeError("No sysconf detected.") - return os.sysconf("SC_NPROCESSORS_ONLN") - -All the settings are mentionned in the :ref:`settings ` list. +All the settings are mentioned in the :ref:`settings ` list. Framework Settings From f5f5461ab8959b242111097d16707803a9375cfb Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 18 May 2014 01:30:36 +0300 Subject: [PATCH 13/20] Fix a couple of typos. --- docs/source/2012-news.rst | 4 ++-- docs/source/install.rst | 2 +- docs/source/news.rst | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/2012-news.rst b/docs/source/2012-news.rst index fdba1e3c..cba5a55d 100644 --- a/docs/source/2012-news.rst +++ b/docs/source/2012-news.rst @@ -23,7 +23,7 @@ Changelog - 2012 - **Added support for Python 3.2 & 3.3** - Expose --pythonpath command to all gunicorn commands -- Honor $PORT environment variable, useful for deployement on heroku +- Honor $PORT environment variable, useful for deployment on heroku - Removed support for Python 2.5 - Make sure we reopen the logs on the console - Fix django settings module detection from path @@ -82,7 +82,7 @@ Changelog - 2012 - improvement: performance of http.body.Body.readline() - improvement: log HTTP errors in access log like Apache -- improvment: display traceback when the worker fails to boot +- improvement: display traceback when the worker fails to boot - improvement: makes gunicorn work with gevent 1.0 - examples: websocket example now supports hybi13 - fix: reopen log files after initialization diff --git a/docs/source/install.rst b/docs/source/install.rst index 0efcd72e..0e1b2087 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -26,7 +26,7 @@ Python package:: $ pip install git+https://github.com/benoitc/gunicorn.git -This will allow you To keep up to date with development on GitHub:: +This will allow you to keep up to date with development on GitHub:: $ pip install -U git+https://github.com/benoitc/gunicorn.git diff --git a/docs/source/news.rst b/docs/source/news.rst index 6cb61bc2..2a11e8d1 100644 --- a/docs/source/news.rst +++ b/docs/source/news.rst @@ -116,7 +116,7 @@ service release. - **Added support for Python 3.2 & 3.3** - Expose --pythonpath command to all gunicorn commands -- Honor $PORT environment variable, useful for deployement on heroku +- Honor $PORT environment variable, useful for deployment on heroku - Removed support for Python 2.5 - Make sure we reopen the logs on the console - Fix django settings module detection from path @@ -175,7 +175,7 @@ service release. - improvement: performance of http.body.Body.readline() - improvement: log HTTP errors in access log like Apache -- improvment: display traceback when the worker fails to boot +- improvement: display traceback when the worker fails to boot - improvement: makes gunicorn work with gevent 1.0 - examples: websocket example now supports hybi13 - fix: reopen log files after initialization From 39dbe983c38c8d2fd6182c4955f11ceb3f333342 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 18 May 2014 02:01:42 +0300 Subject: [PATCH 14/20] Fix markup of the access_log_format documentation. --- docs/source/settings.rst | 41 ++++++++++++++++++++-------------------- gunicorn/config.py | 40 +++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/docs/source/settings.rst b/docs/source/settings.rst index 2f8edaeb..38a9b0d1 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -421,28 +421,27 @@ access_log_format * ``--access-logformat STRING`` * ``%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"`` -The Access log format . +The access log format. -By default: - -%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" - - -| h: remote address -| l: '-' -| u: currently '-', may be user name in future releases -| t: date of the request -| r: status line (ex: GET / HTTP/1.1) -| s: status -| b: response length or '-' -| f: referer -| a: user agent -| T: request time in seconds -| D: request time in microseconds -| L: request time in decimal seconds -| p: process ID -| {Header}i: request header -| {Header}o: response header +========== =========== +Identifier Description +========== =========== +h remote address +l '-' +u currently '-', may be user name in future releases +t date of the request +r status line (e.g. ``GET / HTTP/1.1``) +s status +b response length or '-' +f referer +a user agent +T request time in seconds +D request time in microseconds +L request time in decimal seconds +p process ID +{Header}i request header +{Header}o response header +========== =========== errorlog ~~~~~~~~ diff --git a/gunicorn/config.py b/gunicorn/config.py index 6cadd09b..ab0040bd 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -962,27 +962,27 @@ class AccessLogFormat(Setting): validator = validate_string default = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"' desc = """\ - The Access log format . + The access log format. - By default: - - %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" - - - | h: remote address - | l: '-' - | u: currently '-', may be user name in future releases - | t: date of the request - | r: status line (ex: GET / HTTP/1.1) - | s: status - | b: response length or '-' - | f: referer - | a: user agent - | T: request time in seconds - | D: request time in microseconds, - | p: process ID - | {Header}i: request header - | {Header}o: response header + ========== =========== + Identifier Description + ========== =========== + h remote address + l '-' + u currently '-', may be user name in future releases + t date of the request + r status line (e.g. ``GET / HTTP/1.1``) + s status + b response length or '-' + f referer + a user agent + T request time in seconds + D request time in microseconds + L request time in decimal seconds + p process ID + {Header}i request header + {Header}o response header + ========== =========== """ From ecdae40c680e55a277f742747b739c10771921d6 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Sun, 18 May 2014 03:01:18 +0300 Subject: [PATCH 15/20] Sync settings documentation with gunicorn/config.py. --- docs/source/settings.rst | 18 ++++++++++++++---- gunicorn/config.py | 5 +++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/docs/source/settings.rst b/docs/source/settings.rst index 38a9b0d1..476355c1 100644 --- a/docs/source/settings.rst +++ b/docs/source/settings.rst @@ -73,6 +73,9 @@ A positive integer generally in the 2-4 x $(NUM_CORES) range. You'll want to vary this a bit to find the best for your particular application's work load. +By default, the value of the WEB_CONCURRENCY environment variable. If +it is not defined, the default is 1. + worker_class ~~~~~~~~~~~~ @@ -215,8 +218,10 @@ debug * ``--debug`` * ``False`` -**DEPRECATED**: This no functionality was removed after v18.0. This -option is now a no-op. +Turn on debugging in the server. + +**DEPRECATED**: This no functionality was removed after v18.0. +This option is now a no-op. reload ~~~~~~ @@ -609,10 +614,15 @@ e.g. paste ~~~~~ -* ``--paster STRING`` +* ``--paste STRING, --paster STRING`` * ``None`` -Load a paste.deploy config file. +Load a paste.deploy config file. The argument may contain a "#" symbol +followed by the name of an app section from the config file, e.g. +"production.ini#admin". + +At this time, using alternate server blocks is not supported. Use the +command line arguments to control server configuration instead. Server Hooks ------------ diff --git a/gunicorn/config.py b/gunicorn/config.py index ab0040bd..51125f2f 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -425,6 +425,7 @@ def get_default_config_file(): return None +# Please remember to run "make html" in docs/ after update "desc" attributes. class ConfigFile(Setting): name = "config" section = "Config File" @@ -527,7 +528,7 @@ class WorkerClass(Setting): * ``sync`` * ``eventlet`` - Requires eventlet >= 0.9.7 - * ``gevent`` - Requires gevent >= 0.12.2 (?) + * ``gevent`` - Requires gevent >= 0.13 * ``tornado`` - Requires tornado >= 0.2 Optionally, you can provide your own worker by giving gunicorn a @@ -799,7 +800,7 @@ class Env(Setting): $ gunicorn -b 127.0.0.1:8000 --env FOO=1 test:app - and test for the foo variable environement in your application. + and test for the foo variable environment in your application. """ From 223ab2a3f3b85286dcd7619740734e98d6ea04d4 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Sat, 17 May 2014 17:04:13 -0700 Subject: [PATCH 16/20] Remove reference to unmaintained py24 branch --- docs/source/install.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/docs/source/install.rst b/docs/source/install.rst index 0e1b2087..913a996d 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -10,14 +10,6 @@ To install the latest released version of Gunicorn:: $ pip install gunicorn -.. note:: - There is a limited support version of Gunicorn that is compatible - with Python 2.4. This fork is managed by Randall Leeds and can be - found `here on GitHub`_. To install this version via ``pip``, you - must specify the *py24* branch:: - - $ pip install git+https://github.com/tilgovi/gunicorn.git@py24 - From Source =========== @@ -154,7 +146,6 @@ Replace *lucid* with your Ubuntu distribution series. .. _`design docs`: design.html .. _Eventlet: http://eventlet.net -.. _`here on GitHub`: http://github.com/tilgovi/gunicorn .. _Gevent: http://gevent.org .. _libevent: http://monkey.org/~provos/libevent .. _Debian: http://www.debian.org/ From 6248208ae0c2747657a00193b3ebf078e94bb1e2 Mon Sep 17 00:00:00 2001 From: TedWantsMore Date: Wed, 21 May 2014 15:49:50 -0700 Subject: [PATCH 17/20] Update deploy.rst --- docs/source/deploy.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/deploy.rst b/docs/source/deploy.rst index 08cfb963..da537e2d 100644 --- a/docs/source/deploy.rst +++ b/docs/source/deploy.rst @@ -169,7 +169,7 @@ Create a ``Procfile`` in your project:: gunicorn = gunicorn -w 3 test:app -You can any other applications that should be launched at the same time. +You can launch any other applications that should be launched at the same time. Then you can start your gunicorn application using `gaffer `_.:: From e9e04aa6c6a4f72a06eec443feecd482e2bea733 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Thu, 22 May 2014 09:23:39 +0300 Subject: [PATCH 18/20] Use six.string_types instead of basestring. --- gunicorn/glogging.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 0ee3452b..8285c798 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -84,7 +84,7 @@ class SafeAtoms(dict): def __init__(self, atoms): dict.__init__(self) for key, value in atoms.items(): - if isinstance(value, basestring): + if isinstance(value, string_types): self[key] = value.replace('"', '\\"') else: self[key] = value From 0e78e785982dacdb9af6a2be17262f6739f947d0 Mon Sep 17 00:00:00 2001 From: Matt Robenolt Date: Mon, 26 May 2014 20:20:15 -0700 Subject: [PATCH 19/20] Update nginx config to reflect best practice Should use `try_files` then fall back to a named location block. This is also what's recommended inside the docs already: http://gunicorn-docs.readthedocs.org/en/latest/deploy.html#nginx-configuration --- examples/nginx.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/nginx.conf b/examples/nginx.conf index 5ed8f87c..6e361d06 100644 --- a/examples/nginx.conf +++ b/examples/nginx.conf @@ -86,6 +86,11 @@ http { root /path/to/app/current/public; location / { + # checks for static file, if not found proxy to app + try_files $uri @proxy_to_app; + } + + location @proxy_to_app { # an HTTP header important enough to have its own Wikipedia entry: # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; From d7c7c59bdbc1624f249fedf55d4af0e97fd58447 Mon Sep 17 00:00:00 2001 From: Matt Robenolt Date: Mon, 26 May 2014 20:24:09 -0700 Subject: [PATCH 20/20] Consistent usage of `@proxy_to_app` named location This can be confusing since `location / {}` and `location @proxy_to_app {}` were both being used. --- docs/source/deploy.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/deploy.rst b/docs/source/deploy.rst index da537e2d..152f1309 100644 --- a/docs/source/deploy.rst +++ b/docs/source/deploy.rst @@ -77,7 +77,7 @@ To turn off buffering, you only need to add ``proxy_buffering off;`` to your ``location`` block:: ... - location / { + location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off;