Edgewall Software

Changes between Version 8 and Version 9 of Gunicorn


Ignore:
Timestamp:
Feb 18, 2015, 5:18:01 PM (9 years ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • Gunicorn

    v8 v9  
    1 = Running Trac with Gunicorn =
     1= Running Trac with Gunicorn
    22
    3 Gunicorn (Green Unicorn) is a Python WSGI HTTP Server for UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy.
    4 
     3[http://gunicorn.org/ Gunicorn] (Green Unicorn) is a Python WSGI HTTP Server for UNIX. It is a pre-fork worker model ported from Ruby's Unicorn project. The Gunicorn server is broadly compatible with various web frameworks, simply implemented, light on server resources, and fairly speedy.
    54
    65 1. Install gunicorn
    76
    8 Gunicorn is a python project which lives on pypi, so we can use easy_install or pip to install gunicorn :
     7Gunicorn is a Python project which lives on pypi, so we can use easy_install or pip to install gunicorn:
    98
    109{{{
     
    1413I prefer to use a virtualenv (http://pypi.python.org/pypi/virtualenv), to not have to install gunicorn in a system wide fashion.
    1514
    16 
    1715 2. Write your wsgi file
    1816
    19 Gunicorn is WSGI compliant, so we need a simple python script `tracwsgi.py` that work as an entry point:
     17Gunicorn is [http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface WSGI compliant], so we need a simple Python script `tracwsgi.py` that work as an entry point:
    2018
    2119{{{
     
    3533}}}
    3634
    37 Now, we will test it:
     35Now to test it:
    3836
    3937{{{
     
    4745}}}
    4846
    49 Now, launch your web browser, and go to http://yourip:8000 and it should work.
    50 How it works: gunicorn is looking for a method called "application" in the tracwsgi.py file
    51 
     47In your web browser go to http://yourIP:8000 and it should work.
     48How it works: gunicorn is looking for a method called "application" in the tracwsgi.py file.
    5249
    5350 3. Configure Nginx
    5451
    55 So, now we have Gunicorn running, but we will make it work with nginx which will redirect Trac requests to gunicorn:
     52So, now we have Gunicorn running, but we will make it work with Nginx which will redirect Trac requests to gunicorn:
    5653
    5754{{{
     
    8380}
    8481
    85 
    8682}}}
    8783
    88 Note: Nginx will redirect requests to a unix socket. It can be a simple ip:port combination. It can be a multiple instance of gunicorn. Take a look in the nginx documentation:
     84'''Note''': Nginx will redirect requests to a UNIX socket. It can be a simple ip:port combination. It can be a multiple instance of gunicorn. Take a look in the Nginx documentation:
    8985http://wiki.nginx.org/HttpUpstreamModule
    9086
    9187To add a basic or digest authentication, you'll have to provide a file as in the example above, created using htpasswd file.
    92 To make gunicorn listen on a unix socket, add this option :
     88To make gunicorn listen on a unix socket, add this option:
    9389
    9490{{{
     
    9894}}}
    9995
    100 Note: It seems the WSGI entry point does not handle the Digest or Basic http authentication. To ensure the authentication middleware is passed, you have to hack a little bit the tracwsgi.py:
     96'''Note''': It seems the WSGI entry point does not handle the Digest or Basic http authentication. To ensure the authentication middleware is passed, you have to hack a little bit the tracwsgi.py:
    10197
    10298{{{
     
    118114}}}
    119115
    120 Another note: if using digest authentication you must create the authentication handler outside of the application def, otherwise the !DigestAuthentication object won't retain state between requests.
     116'''Note''': if using digest authentication you must create the authentication handler outside of the application def, otherwise the !DigestAuthentication object won't retain state between requests.
    121117
    122118{{{