File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 99import sys
1010import time
1111import traceback
12+ import socket
1213
1314from gunicorn .errors import HaltServer , AppImportError
1415from gunicorn .pidfile import Pidfile
@@ -151,7 +152,8 @@ def start(self):
151152 for fd in os .environ .pop ('GUNICORN_FD' ).split (',' ):
152153 fds .append (int (fd ))
153154
154- self .LISTENERS = sock .create_sockets (self .cfg , self .log , fds )
155+ if not (self .cfg .reuse_port and hasattr (socket , 'SO_REUSEPORT' )):
156+ self .LISTENERS = sock .create_sockets (self .cfg , self .log , fds )
155157
156158 listeners_str = "," .join ([str (lnr ) for lnr in self .LISTENERS ])
157159 self .log .debug ("Arbiter booted" )
@@ -604,6 +606,8 @@ def spawn_worker(self):
604606 try :
605607 util ._setproctitle ("worker [%s]" % self .proc_name )
606608 self .log .info ("Booting worker with pid: %s" , worker .pid )
609+ if self .cfg .reuse_port :
610+ worker .sockets = sock .create_sockets (self .cfg , self .log )
607611 self .cfg .post_fork (self , worker )
608612 worker .init_process ()
609613 sys .exit (0 )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def patch(self):
4141 sockets = []
4242 for s in self .sockets :
4343 sockets .append (socket .socket (s .FAMILY , socket .SOCK_STREAM ,
44- fileno = s .sock .fileno ()))
44+ fileno = s .sock .detach ()))
4545 self .sockets = sockets
4646
4747 def notify (self ):
You can’t perform that action at this time.
0 commit comments