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 9
9
import sys
10
10
import time
11
11
import traceback
12
+ import socket
12
13
13
14
from gunicorn .errors import HaltServer , AppImportError
14
15
from gunicorn .pidfile import Pidfile
@@ -151,7 +152,8 @@ def start(self):
151
152
for fd in os .environ .pop ('GUNICORN_FD' ).split (',' ):
152
153
fds .append (int (fd ))
153
154
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 )
155
157
156
158
listeners_str = "," .join ([str (lnr ) for lnr in self .LISTENERS ])
157
159
self .log .debug ("Arbiter booted" )
@@ -604,6 +606,8 @@ def spawn_worker(self):
604
606
try :
605
607
util ._setproctitle ("worker [%s]" % self .proc_name )
606
608
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 )
607
611
self .cfg .post_fork (self , worker )
608
612
worker .init_process ()
609
613
sys .exit (0 )
Original file line number Diff line number Diff line change @@ -41,7 +41,7 @@ def patch(self):
41
41
sockets = []
42
42
for s in self .sockets :
43
43
sockets .append (socket .socket (s .FAMILY , socket .SOCK_STREAM ,
44
- fileno = s .sock .fileno ()))
44
+ fileno = s .sock .detach ()))
45
45
self .sockets = sockets
46
46
47
47
def notify (self ):
You can’t perform that action at this time.
0 commit comments