1868 Commits

Author SHA1 Message Date
Benoit Chesneau
4bb9090a2f
Merge pull request #2823 from Roffild/patch-1
fix LevelLog in Arbiter.run()
2022-08-06 18:32:38 +02:00
Benoit Chesneau
d7cfc372a5
Merge pull request #2785 from mvdbeek/make_loggers_function_atomic
Make loggers function atomic
2022-08-06 18:29:55 +02:00
focus zheng
c9d01c8019 get address from tuple 2022-07-14 10:19:18 +08:00
focus zheng
69bf1d0cf4 remove changes by isort and lint 2022-07-13 15:44:30 +08:00
Roffild
4dff334f18
fix LevelLog in Arbiter.run() 2022-07-05 14:43:43 +03:00
mvdbeek
f186fa3a27
Make loggers function atomic
Fixes https://github.com/benoitc/gunicorn/issues/2784:
```
Traceback (most recent call last):
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
    worker.init_process()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/uvicorn/workers.py", line 66, in init_process
    super(UvicornWorker, self).init_process()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/workers/base.py", line 116, in init_process
    self.log.close_on_exec()
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 381, in close_on_exec
    for log in loggers():
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 94, in loggers
    return [logging.getLogger(name) for name in existing]
  File "/home/runner/work/galaxy/galaxy/galaxy root/.venv/lib/python3.7/site-packages/gunicorn/glogging.py", line 94, in <listcomp>
    return [logging.getLogger(name) for name in existing]
RuntimeError: dictionary changed size during iteration
```
2022-04-22 15:33:17 +02:00
Hazh. M. Adam
7d8f68c1a7
Solving issue #2692
ValueError: count must be a positive integer (got 0)
2022-04-04 12:27:55 +08:00
Tero Saarni
ac8bc3a455 Regenerated rst docs
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2022-03-15 19:05:30 +02:00
Tero Saarni
6d70be2d1c Merge branch 'master' into sslcontext 2022-03-15 18:55:02 +02:00
DwarfMaster
cc3238c6ff Prevent unnecessary setuid call 2022-03-13 17:16:32 +01:00
Tero Saarni
362a52bd84 Added parameter to ssl_context hook for constructing default context
Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2022-02-11 19:26:56 +02:00
Brett Randall
0b6939de86
Undo changes that make -R branch logic behave the same as non -R branch,
that is, to close(0) and open /dev/null as fd=0 instead of fd=3.

(Partially) Revert "Ensure fd 0 stdin </dev/null is always inheritable."

This partially reverts commit 7946678f271e25473618929d6f2725c8c375563e.
2022-02-07 07:39:46 +11:00
Brett Randall
e9c4f7443e
Revert "Refactoring: common stdin </dev/null."
This reverts commit a4f286769858ecfef14080f815adce26c260b2a9.
2022-02-07 07:39:46 +11:00
Brett Randall
eedc3a38b6
Refactoring: common stdin </dev/null. 2022-02-07 07:39:46 +11:00
Brett Randall
835a4fc420
Ensure fd 0 stdin </dev/null is always inheritable.
When gunicorn --daemon daemonizes the process, prior to this change it was
noted that in the general case (without -R / --enable-stdio-inheritance), when fd 0
was replaced with /dev/null, the dup2 copy is skipped, and per PEP 446
"Make newly created file descriptors non-inheritable", the result was a stdio
fd </dev/null which was non-inheritable.  As a result, any launched subprocess
did not have an open 0/stdin fd, which can cause problems in some applications.

This change retains the behaviour of opening /dev/null with fd 0, but adds a call
to os.set_inheritable(..) to ensure the fd is inheritable.

The -R branch had different logic but has now been standardised with the general
case.  It was previously opening /dev/null as fd 3 and the dup2() copy made it
inheritable as fd 0.  This branch now applies the same logic: open as fd 0
(i.e. after close(0)), then set_inheritable.  As a result, an extra fd 3 </dev/null
previously left open is no longer left open.

Signed-off-by: Brett Randall <javabrett@gmail.com>
2022-02-07 07:39:46 +11:00
Kian-Meng Ang
cf3619f831 Fix typos 2022-01-14 23:34:02 +08:00
benoitc
76f8da24cb Revert "Log a warning when a worker was terminated due to a signal"
This reverts commit b695b497b9b8e7351808848ab9e342219601742a.
2021-12-17 15:16:34 +01:00
Dariusz Działak
c30b0d9d59 Fix problem that may happen after interrupted chunk-encoding request
more in bug report: https://github.com/benoitc/gunicorn/issues/2684

Fixes #2684
2021-11-15 11:27:15 +01:00
Vytautas Liuolia
f639128bd7 Fix sendfile behaviour for open files with non-zero offset. 2021-11-12 21:39:10 +01:00
Paul Miller
e3b0b1f91a
integral? that took me a while to figure out
integral: "In mathematics, an integral assigns numbers to functions in a way that describes displacement, area, volume, and other concepts that arise by combining infinitesimal data."

integer: an int type
2021-10-08 21:04:12 -04:00
Tero Saarni
5a581c0b14 Update SSLContext handling
* Change deprecated ssl.wrap_socket() to SSLContext.wrap_context().
* Add new server hook to allow user to create custom SSLContext.
* Updated the documentation.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
2021-09-12 17:39:06 +03:00
duanhongyi
df82cac7d9 fix: gunicorn run tornado app failed 2021-09-01 18:06:28 +08:00
yingjie
0215f5dc36 docs: add examples for cert-reqs 2021-08-26 22:41:12 +08:00
laggardkernel
7d50d61f94 Fix calling condition for Arbiter.log.reopen_files()
`GUNICORN_FD` is not always set in a `reexec`ed child process.
Considering `Arbiter.master_pid` is set after log reopening,
choose `GUNICORN_PID`.
2021-06-22 12:21:13 +08:00
Sergey Shepelev
6a8ebb4844 eventlet worker: ALREADY_HANDLED -> WSGI_LOCAL
Eventlet v0.30.3+ removed wsgi.ALREADY_HANDLED in favor of
`wsgi.WSGI_LOCAL.already_handled: bool`

Sorry, this breaking change happened during only patch
version increase 0.30.2 -> 0.30.3

https://github.com/eventlet/eventlet/issues/543
https://github.com/eventlet/eventlet/pull/544
2021-06-09 21:49:48 +03:00
Karthikeyan Singaravelan
927c604fb7 Set daemon attribute instead of using setDaemon method that was deprecated in Python 3.10 2021-04-26 12:34:01 +00:00
Michael Milton
b83448bfb4
Clarify the secure scheme behaviour, with examples (#2492) 2021-03-08 10:58:22 -08:00
Smiler Lee
fb05e33377 Fix a naming error for gthread worker 2021-02-24 17:43:17 +08:00
Benoit Chesneau
61ccfd6c38 bump to 20.1.0 2021-02-12 22:43:44 +01:00
sergeypeloton
540b7100b3
Use warning level for 'Bad request' logs
#2491 
Debug level might not be practical to enable in production.
2021-01-08 14:36:14 -05:00
Adam Johnson
6fd97b9559 Document that WEB_CONCURRENCY is set by, at least, Heroku 2021-01-06 03:14:31 +02:00
Adam Johnson
dad99a1bd4 Update gunicorn_ext.py 2021-01-06 03:14:31 +02:00
Randall Leeds
86eac4ce94
Merge pull request #2479 from benoitc/capture-peer-name
Capture peer name from accept
2020-12-31 11:24:11 -05:00
Randall Leeds
c097bec0cc
Merge pull request #2476 from benoitc/fix/1909/no-log-config-dict-cli
Remove the --log-config-dict flag
2020-12-18 20:50:12 -05:00
Randall Leeds
37994e1422 Remove the --log-config-dict flag
There is no support for decoding any dictionary supplied on the command
line. The only way to supply a dictionary logging config is through the
configuration file.

Close #1909.
2020-12-18 20:49:11 -05:00
Randall Leeds
3573fd38d0 Capture peer name from accept
Avoid calls to getpeername by capturing the peer name returned by
accept.
2020-12-17 22:13:02 -05:00
Benoit Chesneau
7ca05ec4e1
Merge pull request #2475 from m2p-consulting/log-killed
Log a warning when a worker was terminated due to a signal
2020-12-17 11:29:04 +01:00
Randall Leeds
b7f2a82731
Merge pull request #2277 from JordanP/graceful-enotconn
Do not raise and crash worker on ENOTCONN error
2020-12-16 19:09:35 -05:00
Armin Berres
b695b497b9 Log a warning when a worker was terminated due to a signal
This happens for example when being OOM killed.

See #2215
2020-12-16 11:05:27 +01:00
Joshua Kugler
da3b89b765 The signature of __init__ on the "fall through" InotifyReloader
was missing the extra_files paramater, so specifying the inotify
reload engine on the command line when one did not have inotify
installed would, instead of a nice message about needed inotify
installed would result in the following traceback:

```
[2020-10-30 00:55:43 +0000] [7] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/gunicorn/arbiter.py", line 583, in spawn_worker
    worker.init_process()
  File "/usr/lib/python3/dist-packages/gunicorn/workers/base.py", line 132, in init_process
    self.reloader = reloader_cls(extra_files=self.cfg.reload_extra_files,
TypeError: __init__() got an unexpected keyword argument 'extra_files'
```

I didn't see an easy way to writing a test for this, but would be
happy to take pointers.
2020-10-29 17:26:59 -08: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
Chris Mildebrandt
ca36d410fd Fix format call 2020-09-11 23:05:38 -07:00
Chris Mildebrandt
28df9926d7 Add additional logs when worker exits abnormally 2020-09-11 22:41:27 -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
Ken Okada
f2d8b6d100 Split long line 2020-08-24 21:15:31 +09: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
Ken Okada
d81c6cefcb Warn in the case of bad systemd configuration 2020-08-20 09:00:03 +09:00
larribas
2a16fcd3ce Test and defend against the specific case where the statsd hostname is 'unix' 2020-07-20 10:16:42 +02:00