mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Add --reuse-port to make use of SO_REUSEPORT optional (#1669)
Fixes #1603
This commit is contained in:
parent
5953148573
commit
6171ac4885
@ -428,6 +428,18 @@ to enable or disable its usage.
|
||||
.. versionchanged:: 19.6
|
||||
added support for the ``SENDFILE`` environment variable
|
||||
|
||||
.. _reuse-port:
|
||||
|
||||
reuse_port
|
||||
~~~~~~~~~~
|
||||
|
||||
* ``--reuse-port``
|
||||
* ``False``
|
||||
|
||||
Set the ``SO_REUSEPORT`` flag on the listening socket.
|
||||
|
||||
.. versionadded:: 19.8
|
||||
|
||||
.. _chdir:
|
||||
|
||||
chdir
|
||||
|
||||
@ -204,6 +204,10 @@ class Config(object):
|
||||
|
||||
return True
|
||||
|
||||
@property
|
||||
def reuse_port(self):
|
||||
return self.settings['reuse_port'].get()
|
||||
|
||||
@property
|
||||
def paste_global_conf(self):
|
||||
raw_global_conf = self.settings['raw_paste_global_conf'].get()
|
||||
@ -954,6 +958,21 @@ class Sendfile(Setting):
|
||||
"""
|
||||
|
||||
|
||||
class ReusePort(Setting):
|
||||
name = "reuse_port"
|
||||
section = "Server Mechanics"
|
||||
cli = ["--reuse-port"]
|
||||
validator = validate_bool
|
||||
action = "store_true"
|
||||
default = False
|
||||
|
||||
desc = """\
|
||||
Set the ``SO_REUSEPORT`` flag on the listening socket.
|
||||
|
||||
.. versionadded:: 19.8
|
||||
"""
|
||||
|
||||
|
||||
class Chdir(Setting):
|
||||
name = "chdir"
|
||||
section = "Server Mechanics"
|
||||
|
||||
@ -39,7 +39,8 @@ class BaseSocket(object):
|
||||
|
||||
def set_options(self, sock, bound=False):
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
if hasattr(socket, 'SO_REUSEPORT'): # pragma: no cover
|
||||
if (self.conf.reuse_port
|
||||
and hasattr(socket, 'SO_REUSEPORT')): # pragma: no cover
|
||||
try:
|
||||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
||||
except socket.error as err:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user