2845 Commits

Author SHA1 Message Date
Alex Hill
d8a1256065
Document that gthread also uses worker_connections
The `ThreadWorker` uses `worker_connections` it in its run loop to limit how many connections are accepted.
2020-12-10 16:10:50 +08:00
Moshe Kaplan
548d5828da
Remove reference to gunicorn/six.py in tox.ini (#2427) 2020-09-23 17:31:23 +03:00
Benoit Chesneau
1ae46ca092
Merge pull request #2418 from duanhongyi/master
fix: repair django wsgi running error
2020-09-18 16:36:20 +02:00
Benoit Chesneau
5175471f42 be more explicit in the description of USR2 flow. 2020-09-17 17:10:07 +02:00
Randall Leeds
1d6f902987 Disable pylint raise-missing-from
Pylint 2.6.0 added a new rule to encourage chaining exceptions. Until
someone has time to address the new warnings, disable the rule to avoid
breaking the build.
2020-09-13 15:37:11 -07:00
duanhongyi
83319f752c fix: repair django wsgi running error 2020-09-10 16:13:06 +08:00
Benoit Chesneau
b3f9815aba fix: don't enforce the content length
we were trying to enforce the content length when the websocket
key was received but we should instead rely on the headers provided in
the request. Enforcing the expectation of the content length should be
done by the client side not by us.

Changes:

* remove content-length header enforcing in message.p when the
"Sec-WebSocket-Key1" header was found
2020-08-26 10:56:04 +02:00
Gastón Avila
b80a329354
Correction on default value for config file (#2408)
Running gunicorn project.app while having a file called gunicorn.conf.py
in the current directory will read configuration from that file and actually fail
if the file raises an exception.
2020-08-22 20:13:02 +03:00
Randall Leeds
5001de6070
Merge pull request #2354 from ssanjaysubramaniam/patch-1
Typo/grammar in Deploying Gunicorn docs
2020-07-07 19:35:01 -07:00
Christian Clauss
7e16d13011
Port websocket examples to Python 3 (#2371) 2020-07-02 23:34:11 +03:00
Hugo
e60a5591b0 Add project_urls and update to https 2020-06-21 01:23:45 +03:00
Sanjay
4b9afb47bd
Probably a typo 2020-06-08 11:38:20 +05:30
Randall Leeds
4bed9e7b19
Merge pull request #2344 from tiangolo/dunder-main
 Add support for python -m gunicorn
2020-05-29 11:17:15 -07:00
Sebastián Ramírez
17e70dac53 Add support for python -m gunicorn 2020-05-29 18:44:50 +02:00
Dustin Ingram
6aab4decde Add additional missing docs 2020-05-15 03:30:08 +03:00
Dustin Ingram
d43399796a Update desc for Timeout 2020-05-15 03:30:08 +03:00
Randall Leeds
611a314cff
Merge pull request #2326 from ekohl/patch-1
Correct systemd socket activation example
2020-05-08 09:19:41 -07:00
Ewoud Kohl van Wijngaarden
4ababc368b
Correct systemd socket activation example 2020-05-05 12:49:22 +02:00
Randall Leeds
bac7f0300b
Merge pull request #1450 from hramezani/issue_1359
Specify wsgi_app in config
2020-05-03 16:03:07 -07:00
Hasan Ramezni
57a9e2eb7e Specify wsgi_app in config #1359. 2020-05-01 01:11:21 +02:00
Randall Leeds
b2dc036463
Merge pull request #2292 from di/document-infinite-timouts
Document --timeout 0
2020-04-22 11:09:20 -07:00
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
Dustin Ingram
57b8cdffae
Document --timeout 0 2020-03-16 17:29:07 -05: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