To use the logrotate utility, a USR1 signal is sent, and the
corresponding handler reopens the log files. However, sys.stdout and
sys.stderr, which may be redirected to the error log file, are not
updated. This commit fixes this, by closing the fileobj of the
LazyWriter object. There is no need to reopen it, since the LazyWriter
will open it when needed.
Gunicorn has now the possibility to directly pass the settings env as
argument but it was breaking the old way to do it when giving a path to
the settings file instead.
This changes introduced an issue with websockets support (#432) and is
probably related to #428 & #416 . It is safer for now to revert it.
This reverts commit aa22115cfc9c2b76c818ce231089b01c690052b6.
Conflicts:
gunicorn/workers/async.py
gunicorn/workers/sync.py
This patch makes sure that we now handle correctly bytes and native
strings on python 3:
- In python 3, sockets are now taking and returning bytes.
- according to PEP3333, headers should be native strings and body in
bytes.
`server.kill()` is too aggressive. It sends a GreenletExit exception
to all the pool workers, causing them to exit immediately.
A simple one line fix is to use `server.stop()`. In my testing, it
appears that `server.stop_accepting()` will make the server stop
listening, but pending connections already in the `accept()` backlog
are still handled. With `server.stop()` the accept backlog is not
handled, the listener is closed in the worker, but existing requests
are allowed to exit gracefully.