2823 Commits

Author SHA1 Message Date
Randall Leeds
a232c270fd
Merge pull request #2313 from benoitc/keepalive-graceful-shutdown
Disable keepalive during graceful shutdown
2020-04-20 18:49:08 -07:00
Randall Leeds
839d5dc66c Merge pull request #1996 from javabrett/1690-rewritings 2020-04-20 15:37:41 -07:00
Randall Leeds
4ae2a05c37 Disable keepalive during graceful shutdown
Fix graceful shutdown behavior so that clients receive notice to close
the connection.

After #2304 and the follow-up in ebb41da, Joe Kemp noticed that, while
the new behavior would successfully indicate a connect close after
hitting the maximum request limit for a worker during graceful shutdown,
the worker would not indicate a connection close if if it had not hit
the maximum request limit.

This change ensures that the worker exits gracefully when hitting the
request limit and also indicates to clients that the connection should
close once the shutdown begins.
2020-04-20 14:35:19 -07:00
Randall Leeds
ebb41da472 Make force close on max requests consistent
All worker types should force a connection close after a request that
exceeds the max requests. A worker only needs to log about the automatic
restart once, rather than once for each keepalive request.
2020-04-20 13:13:34 -07:00
Randall Leeds
4591b51db8
Merge pull request #2288 from dekexu/master
Upgrade gthread worker  when behind load balancer
2020-04-20 13:11:55 -07:00
Randall Leeds
ee685e197b Merge pull request #2054 from rcoup/2052-print-config 2020-04-20 12:40:57 -07:00
Randall Leeds
5425af8941
Merge pull request #2249 from trendels/issue-2244
Issue 2244
2020-04-20 12:06:58 -07:00
Randall Leeds
d296cdc7a3
Merge pull request #2312 from benoitc/revert-2304-fix-gevent-loop-exit
Revert "Exit async keepalive request loop when self.alive is False"
2020-04-20 12:02:57 -07:00
Randall Leeds
8c5613b1ad
Revert "Exit async keepalive request loop when self.alive is False" 2020-04-20 12:02:26 -07:00
Randall Leeds
bf14a0f419
Merge pull request #2304 from closeio/fix-gevent-loop-exit
Exit async keepalive request loop when self.alive is False
2020-04-20 11:58:27 -07:00
Joe Kemp
789605704c Exit keepalive request loop when self.alive is False 2020-04-10 16:26:37 -04:00
deco
0896392e09
Merge pull request #1 from dekexu/dekexu-patch-1
Update gthread.py
2020-03-11 20:15:14 +08:00
deco
3bf93193f2
Update gthread.py
upgrade gthread worker when behind load balancer
2020-03-11 20:14:30 +08:00
Benoit Chesneau
8cb2bd2329
Merge pull request #2257 from kmichel-sereema/replace-sitemap-generator
Replace and run the sitemap generator
2020-03-06 10:56:41 +01:00
Jason Madden
46b2cffaee
Merge pull request #2266 from lyft/fix_max_accept_in_gevent
Set `max_accept` on `gevent` worker-class to 1 when workers > 1
2020-03-03 08:24:37 -06:00
Jason Madden
915715262c
Merge pull request #2282 from timgates42/bugfix_typo_convertible
Fix simple typo: convertable -> convertible
2020-03-01 07:29:57 -06:00
Tim Gates
f626830cde
Fix simple typo: convertable -> convertible
There is a small typo in examples/websocket/gevent_websocket.py, examples/websocket/websocket.py.
Should read `convertible` rather than `convertable`.
2020-03-01 19:14:18 +11:00
Roy Williams
f145e90e32 Set max_accept on gevent worker-class to 1 when workers > 1
We've had really terrible tail latencies with gevent and gunicorn under load.

Inspecting our services with strace we see the following:

```
23:11:01.651529 accept4(5, {sa_family=AF_UNIX}, [110->2], SOCK_CLOEXEC) = 223 <0.000015>
..{18 successful calls to accept4}...
23:11:01.652590 accept4(5, {sa_family=AF_UNIX}, [110->2], SOCK_CLOEXEC) = 249 <0.000010>
23:11:01.652647 accept4(5, 0x7ffcd46c09d0, [110], SOCK_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable) <0.000012>
23:11:01.657622 getsockname(5, {sa_family=AF_UNIX, sun_path="/run/gunicorn/gunicorn.sock"}, [110->30]) = 0 <0.000009>
23:11:01.657682 recvfrom(223, "XXX"..., 8192, 0, NULL, NULL) = 511 <0.000011>
..{16 calls to recvfrom}...
23:11:01.740726 recvfrom(243, "XXX"..., 8192, 0, NULL, NULL) = 511 <0.000012>
23:11:01.746074 getsockname(5, {sa_family=AF_UNIX, sun_path="/run/gunicorn/gunicorn.sock"}, [110->30]) = 0 <0.000013>
23:11:01.746153 recvfrom(246, "XXX"..., 8192, 0, NULL, NULL) = 511 <0.000014>
23:11:01.751540 getsockname(5, {sa_family=AF_UNIX, sun_path="/run/gunicorn/gunicorn.sock"}, [110->30]) = 0 <0.000010>
23:11:01.751599 recvfrom(249, "XXX"..., 8192, 0, NULL, NULL) = 511 <0.000013>
```

Notice we see a flury of 20 `accept4`s followed by 20 calls to to `recvfrom`.  Each call to `recvfrom` happens 5ms after the previous,
so the last `recvfrom` is called ~100ms after the call to `accept4` for that fd.

gevent suggest setting `max_accept` to a lower value when there's multiple working processes on the same listening socket: 785b7b5546/src/gevent/baseserver.py (L89-L102)
gevent sets `max_accept` to `1` when `wsgi.multiprocess` is True: 9d27d269ed/src/gevent/pywsgi.py (L1470-L1472)
gunicorn does in fact set this when the number of workers is > 1: e4e20f273e/gunicorn/http/wsgi.py (L73)
and this gets passed to `gevent.pywsgi.WSGIServer`: e4e20f273e/gunicorn/workers/ggevent.py (L67-L75)
However, when `worker-class` is `gevent` we directly create a `gevent.server.StreamServer`: e4e20f273e/gunicorn/workers/ggevent.py (L77-L78)

Fixing this dropped the p50 response time on an especially probelmatic benchmark from 250ms to 115ms.
2020-02-12 20:35:10 -05:00
Stanis Trendelenburg
f39b065d4b Validate directory before watching it with inotify
Fixes this exception that is raised when the inotify-based reloader is used in
combination with the `--chdir` option:

    inotify.calls.InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)
2020-02-02 22:58:31 +01:00
Stanis Trendelenburg
27d1e9887a Fix issues #2133 and #2244
Start reloader after loading the WSGI app.
2020-02-02 22:57:14 +01:00
Randall Leeds
7d8c92f48a
Merge pull request #2253 from kmichel-sereema/2247-document-environment-variables
Document environment variables and $PORT
2020-01-31 09:42:16 -08:00
Randall Leeds
f09d609cc0
Merge pull request #2254 from kmichel-sereema/remove-dead-code-find-library
Remove dead code: find_library and _findWalk_ldpath
2020-01-31 09:41:12 -08:00
Kevin Michel
93bcf5a41e Replace and run the sitemap generator
This replaces the very old sitemap generator which was over 2kloc and
only compatible with Python 2.

According to the stored lastmod, the generator wasn't used since 2010.

The minimal replacement script scan the static site for html files and
uses git to deduce the last modification date of each page.

The sitemap xmlns version was updated to the latest 0.9 from
sitemaps.org .

The index page was given a higher priority since the other pages
are just redirects to the index with anchors.

The output file is pretty printed to help with diffs.

Static assets (css, images...) aren't listed in the sitemap anymore.
2020-01-31 14:21:00 +01:00
Kevin Michel
83b78e09c1 Document the default name and path for the configuration file 2020-01-31 09:48:14 +01:00
Kevin Michel
a648f8a838 Document how environment variables impact configuration 2020-01-31 09:48:14 +01:00
Kevin Michel
c82996f791 Add documentation for the $PORT environment variable 2020-01-30 15:34:37 +01:00
Anmar85
d307045984
Add milliseconds option to request_time in access_log (#2218)
Add milliseconds option to request_time in access_log
2020-01-30 15:29:25 +01:00
Kevin Michel
287916a5d4 Remove dead code: find_library and _findWalk_ldpath 2020-01-29 16:14:33 +01:00
Brett Randall
73ae195068
Merge pull request #2243 from benoitc/pep301-development-status
Updated Development Status 5 - Production/Stable
2020-01-21 08:59:44 +11:00
Brett Randall
9219da52cd
Updated setup Development Status metadata to 5 - Production/Stable (was 4 - Beta).
Signed-off-by: Brett Randall <javabrett@gmail.com>
2020-01-20 10:08:16 +11:00
Brett Randall
77f33d6944
Merge pull request #2238 from benoitc/examples-frameworks-requirements
Added pip requirements files for examples/frameworks
2020-01-17 14:25:17 +11:00
Brett Randall
c1bea68fce
Added a set of pip requirements files to cover the examples in examples/frameworks.
Signed-off-by: Brett Randall <javabrett@gmail.com>
2020-01-14 06:25:46 +11:00
Benoit Chesneau
e4e20f273e
Merge pull request #2233 from benoitc/remove-version-in-server-header
remove version from the Server header
2020-01-11 19:17:51 +01:00
Benoit Chesneau
f74f926f36 remove trailing new line 2020-01-10 13:58:29 +01:00
Benoit Chesneau
dcfd0f04e8 fix SERVER_SOFTWARE property
WSGI spec requires the SERVER_SOFTWARE property containing the name and version. This change fix it and separate the version header from SERVER_SOFTWARE property. We expose the SERVER variable so custom installations can change it in one place without looking much when needed.
2020-01-10 13:50:53 +01:00
Benoit Chesneau
2f944c9bea remove version from the Server header
while we still want to know which server is running to ease operation, the version was giving too much information on the installation, so let's remove it.
2020-01-10 11:00:00 +01:00
Jason Madden
abc621beea
Merge pull request #2230 from benoitc/issue2223
Use socket.sendfile() instead of os.sendfile().
2020-01-06 04:54:26 -06:00
Jason Madden
2d40e6dace
Use socket.sendfile() instead of os.sendfile().
Fixes #2223.

Unfortunately, eventlet doesn't implement GreenSocket.sendfile, so we have to do it for it.

Add gevent and eventlet to tox.ini and add tests to make sure we can at least import the workers. Some tests that this actually functions would be nice...

Update the gevent and eventlet setup extras to require the versions that are enforced in their worker modules.
2020-01-04 06:31:25 -06:00
Brett Randall
9c1438f013
Merge pull request #2229 from benoitc/docs-3-5-min
Updated requires Python to >= 3.5
2020-01-02 06:56:13 +11:00
Brett Randall
1e0ab52405
Merge pull request #2228 from benoitc/no-universal-wheel
Don't build universal wheel, as Python 2 support has been removed
2020-01-02 06:55:49 +11:00
Brett Randall
2ec7493bcb
Updated requires Python to >= 3.5. 2020-01-01 12:58:43 +11:00
Brett Randall
7cce20e937
Don't build universal wheel, since Python 2 support has been removed.
This reverts commit 765b8ab48b6fb991eeb9bcf4f60c0cba6f48359f .
2020-01-01 11:35:53 +11:00
Randall Leeds
57fbbce554
Merge pull request #2227 from mikaeldusenne/hotfix/empty-dirname-inotify
add os.path.abspath() in dirname generation of the reloader
2019-12-30 12:59:54 -08:00
Randall Leeds
e636bf8198
Merge pull request #1784 from tnir/1599-pycodestyle-ci
Enable pycodestyle
2019-12-30 12:58:17 -08:00
Mikaël Dusenne
e5310d15e9 add os.path.abspath() in dirname generation of the reloader
Otherwise adding a watcher for a file located in the working directory generates an empty dirname, resulting in the following error:
inotify.calls.InotifyError: Call failed (should not be -1): (-1) ERRNO=(0)

Caused by the fact that we call inotify with an empty path
2019-12-30 08:39:03 -05:00
monobaila
cfc93ad701 Update FAQ - Workers Silently Killed. 2019-12-15 09:31:16 +01:00
Wesley Ellis
5a57d595c5 Fix sample command syntax highlighting in run.rst
Extra `:` was causing the syntax highlighting to mess up, resulting in the docs containing the `..code-block:: text` markup
2019-12-14 07:01:56 +03:00
Brett Randall
4ef01b1c10 Bumped py3 min version in setup.py to 3.5 (was 3.4).
Signed-off-by: Brett Randall <javabrett@gmail.com>
2019-12-04 00:41:10 +01:00
Randall Leeds
91e9dcba96
Merge pull request #2210 from benoitc/update-maintainers
Add Brett Randall to MAINTAINERS
2019-12-02 20:46:47 -08:00
Brett Randall
9c147f6649
Added Brett Randall to MAINTAINERS. 2019-12-03 11:35:39 +11:00