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
```
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.
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>
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
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.
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
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.
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.
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.