+
    j                         ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	H
t
Ht ^ RIHt ^ RIHtHtHt ^ RIHtHt  ! R R4      tR# )    N)
HaltServerAppImportError)Pidfile)socksystemdutil)__version__SERVER_SOFTWAREc                     a ] tR t^t oRt^t^t/ t. t/ t	]
P                  tRP                  4        U u. uF  p \        \        RV ,          4      NK  	  up t]! R ]! ]
4       4       4      tR tR tR t]! ]]4      tR tR	 tR
 tR t
R tR tR t]tR tR t R t!R t"R t#R t$R t%R t&R t'R t(R t)R1R lt*R2R lt+R3R lt,R t-R t.R  t/R! t0R" t1R# t2R$ t3R% t4R& t5R' t6R( t7R) t8R* t9R+ t:R, t;R- t<R. t=R/ t>R0t?Vt@R# u up i )4Arbiterz
Arbiter maintain the workers processes alive. It launches or
kills them if needed. It also manages application reloading
via SIGHUP/USR2.
z+HUP QUIT INT TERM TTIN TTOU USR1 USR2 WINCHzSIG%sc              #     "   T FL  pVR ,          R8X  g   K  V^,          R8w  g   K#  \        \        V4      VR,          P                  4       3x  KN  	  R# 5i):N   NSIG_:r   NNN)getattrsignallower).0names   & E/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/arbiter.py	<genexpr>Arbiter.<genexpr>0   sK      >Id8u 	2!%aC 	2	R 01ks   AA/Ac                ,   \         \        P                  R &   RV n        RV n        RV n        \        P                  ! 4       V n        V P                  V4       RV n
        RV n        ^ V n        ^ V n        ^ V n        RV n        ^ V n        RV n        RV n        RV n        RRR^ R^ R^ /V n        \*        P,                  ! 4       p\.        P0                  R,          pVP3                  ^ \.        P4                  4       R	VR
V^ \.        P4                  /V n        R# )r
   NFMaster
start_timeworkers_spawnedworkers_killedreloads:NNNargscwd)r
   osenviron_num_workers _last_logged_active_worker_countlogqueueSimpleQueue	SIG_QUEUEsetuppidfiler   
worker_age
reexec_pid
master_pidmaster_namedirty_arbiter_piddirty_arbiterdirty_pidfile_control_server_statsr   getcwdsysargvinsert
executable	START_CTX)selfappr    r   s   &&  r   __init__Arbiter.__init__5   s    (7

$% 04- **,

3# "#!!  $ $qaq	
 kkmxx{As~~& D3s~~
    c                    V P                   # N)r#   r:   s   &r   _get_num_workersArbiter._get_num_workersd   s       r>   c                b    V P                   pWn         V P                  P                  WV4       R # r@   )r#   cfgnworkers_changed)r:   value	old_values   && r   _set_num_workersArbiter._set_num_workersg   s'    %%	!!!$y9r>   c                   Wn         VP                  V n        V P                  f+   V P                  P                  VP                  4      V n        R\        P
                  9   d   V P                  P                  4        V P                  P                  V n        V P                  P                  V n        V P                  P                  V n
        V P                  P                  V n        V P                  P                  V n        V P                  P                  RP                  RP                  R \!        V P                  P"                  P%                  4       R R7       4       4      4      4       V P                  P&                  '       dA   V P                  P&                  P%                  4        F  w  r#V\        P
                  V&   K  	  V P                  P(                  '       d   V P                   P+                  4        R # R # )NGUNICORN_PIDzCurrent configuration:
{0}
c              3   \   "   T F"  w  rR P                  WP                  4      x  K$  	  R# 5i)z
  {0}: {1}N)formatrG   )r   configrG   s   &  r   r    Arbiter.setup.<locals>.<genexpr>   s2      ;: "F ##FKK88:s   *,c                     V ^,          #     )settings   &r   <lambda>Arbiter.setup.<locals>.<lambda>   s    gajr>   key)r;   rE   r%   logger_classr!   r"   reopen_filesworker_classaddressworkersnum_workerstimeout	proc_namedebugrO   joinsortedsettingsitemsenvpreload_appwsgi)r:   r;   kvs   &&  r   r)   Arbiter.setupm   s^   7788xx,,SWW5DH RZZ'HH!!# HH11xx''88++xx''++4;;II ; $((++1138:; ;< 	= 88<<<**, !

1 - 88HHMMO  r>   c                    V P                   P                  R\        4       \        P                  ! 4       V P                  R&   R\
        P                  9   dM   \        \
        P                  P                  R4      4      V n	        V P                  R,           V n
        RV n        \
        P                  ! 4       V n        V P                  P                  ef   V P                  P                  pV P                  ^ 8w  d
   VR,          p\!        V4      V n        V P                  P#                  V P                  4       V P                  P%                  V 4       V P'                  4        V P(                  '       Eg   Rp\*        P,                  ! 4       pV'       d8   RV n        \/        \*        P0                  \*        P0                  V,           4      pMcV P                  '       dR   . p\
        P                  P3                  R4      P5                  R	4       F  pVP7                  \        V4      4       K  	  V P                  P8                  '       d   \;        \<        R
4      '       g2   \>        P@                  ! V P                  V P                   V4      V n        R	PC                  V P(                   Uu. uF  p\E        V4      NK  	  up4      pV P                   PG                  R4       V P                   P                  RW`P                  4       V P                   P                  RV P                  PH                  4       \*        PJ                  ! RV P                   4       \;        V PL                  R4      '       d1   V PL                  PO                  V P                  V P                   4       V P                  PP                  ^ 8  d-   V P                  PR                  '       d   V PU                  4        V P                  PW                  V 4       R# u upi )zKInitialize the arbiter. Start listening and set pidfile if needed.
        zStarting gunicorn %sr   rL   z.2zMaster.2NTGUNICORN_FD,SO_REUSEPORTzArbiter bootedzListening at: %s (%s)zUsing worker: %sz&READY=1
STATUS=Gunicorn arbiter bootedcheck_config),r%   infor	   timer3   r!   r"   intgetr-   rb   r.   getpidpidrE   r*   r   createon_startinginit_signals	LISTENERSr   
listen_fdsrangeSD_LISTEN_FDS_STARTpopsplitappend
reuse_porthasattrsocketr   create_socketsrd   strrc   worker_class_str	sd_notifyr]   rr   dirty_workers
dirty_appsspawn_dirty_arbiter
when_ready)r:   pidnamefdsr}   fdlnrlisteners_strs   &      r   startArbiter.start   s    	,k: %)IIKL!RZZ'!"**.."@ADO!^^d2DN)D99;88'hh&&G!#4"7+DLLL)T"~~~C ++-J#G77#77*DF **..7==cBBJJs2w' C HH'''GFN,K,K!%!4!4TXXtxx!Mdnn!Ens#c(n!EF'(-}hhG($((*C*CDCTXXN 4$$n55**488TXX> 88!!A%$((*=*=*=$$&
 	D!# "Fs   .Pc                    V P                   P                  4        V P                   F#  p\        P                  ! WP                  4       K%  	  \        P                  ! \        P                  V P
                  4       R# )zjInitialize master signal handling. Most of the signals
are queued. Child signals only wake up the master.
N)r%   close_on_execSIGNALSr   SIGCHLDsignal_chld)r:   ss   & r   r{   Arbiter.init_signals   sL    
 	  AMM![[) fnnd&6&67r>   c                <    V P                   P                  V4       R# )z3Signal handler - NO LOGGING, just queue the signal.Nr(   
put_nowaitr:   sigframes   &&&r   r   Arbiter.signal       !!#&r>   c                   V P                  4        \        P                  ! RV P                  ,          4        V P	                  4        V P                  4         V P                  4        V P                  RR7       F  pWP                  9  d   V P                  P                  RV4       K1  V P                  P                  V4      p\        V RV,          R4      pV'       g   V P                  P                  RV4       K  V\        P                  8X  d   V P                  P                   MV P                  P                  pV! R	V4       V! 4        K  	  V P#                  4        V P	                  4        V P%                  4        EK1    \&        \(        3 d    T P+                  4         R# \,         d3   pT P+                  TP.                  TP0                  R
7        Rp?R# Rp?i\2         d    h \4         dq    T P                  P                  RRR7       T P7                  R4       T P8                  e   T P8                  P;                  4        \<        P>                  ! R4        R# i ; i)zMain master loop.master [%s]T      ?)ra   zIgnoring unknown signal: %sz	handle_%sNzUnhandled signal: %szHandling signal: %s)reasonexit_statusz Unhandled exception in main loopexc_infoF) r   r   _setproctitlerb   manage_workers_start_control_servermaybe_promote_masterwait_for_signals	SIG_NAMESr%   rs   rv   r   errorr   r   rc   murder_workersmanage_dirty_arbiterStopIterationKeyboardInterrupthaltr   r   r   
SystemExit	Exceptionstopr*   unlinkr5   exit)r:   r   signamehandler	log_levelinsts   &     r   runArbiter.run   s   

=4>>9:)	! &&())+  000=C..0&CSI "nn005G%dK',A4HG"'=wG 252GTXX]]I3W=I > ##%##%))+01 	IIK 	HIIT[[d6F6FIGG 	 	HHNN=$(  *IIe||'##%HHRL	s7   EF
 
!I..I.7I.8'G%%I.2
I.=A-I.-I.c                <    V P                   P                  V4       R# )z;SIGCHLD signal handler - NO LOGGING, just queue the signal.Nr   r   s   &&&r   r   Arbiter.signal_chld	  r   r>   c                F    V P                  4        V P                  4        R# )z6SIGCHLD handling - called from main loop, safe to log.N)reap_workersreap_dirty_arbiterrA   s   &r   handle_chldArbiter.handle_chld  s    !r>   c                    V P                   P                  RV P                  4       V P                  4        V P                  '       d"   V P                  \        P                  4       R# R# )zHUP handling.
- Reload configuration
- Start the new worker processes with a new configuration
- Gracefully shutdown the old worker processes
zHang up: %sN)r%   rs   r.   reloadr/   kill_dirty_arbiterr   SIGHUPrA   s   &r   
handle_hupArbiter.handle_hup  sH     	mT%5%56!!!##FMM2 "r>   c                    \         h)zSIGTERM handling)r   rA   s   &r   handle_termArbiter.handle_term#  s    r>   c                0    V P                  R4       \        h)zSIGINT handlingFr   r   rA   s   &r   
handle_intArbiter.handle_int'      		%r>   c                0    V P                  R4       \        h)zSIGQUIT handlingFr   rA   s   &r   handle_quitArbiter.handle_quit,  r   r>   c                X    V ;P                   ^,          un         V P                  4        R# )z:SIGTTIN handling.
Increases the number of workers by one.
Nr`   r   rA   s   &r   handle_ttinArbiter.handle_ttin1  s!    
 	Ar>   c                ~    V P                   ^8:  d   R# V ;P                   ^,          un         V P                  4        R# )z:SIGTTOU handling.
Decreases the number of workers by one.
Nr   rA   s   &r   handle_ttouArbiter.handle_ttou9  s2    
 q Ar>   c                    V P                   P                  4        V P                  \        P                  4       V P
                  '       d"   V P                  \        P                  4       R# R# )z=SIGUSR1 handling.
Kill all workers by sending them a SIGUSR1
N)r%   r\   kill_workersr   SIGUSR1r/   r   rA   s   &r   handle_usr1Arbiter.handle_usr1C  sI    
 	&..)!!!##FNN3 "r>   c                &    V P                  4        R# )zSIGUSR2 handling.
Creates a new arbiter/worker set as a fork of the current
arbiter without affecting old workers. Use this to do live
deployment with the ability to backout a change.
N)reexecrA   s   &r   handle_usr2Arbiter.handle_usr2N  s     	r>   c                    V P                   P                  '       dD   V P                  P                  R4       ^ V n        V P                  \        P                  4       R# V P                  P                  R4       R# )zSIGWINCH handlingzgraceful stop of workersz SIGWINCH ignored. Not daemonizedN)	rE   daemonr%   rs   r`   r   r   SIGTERMrc   rA   s   &r   handle_winchArbiter.handle_winchW  sK    88???HHMM45 Dfnn-HHNN=>r>   c                   V P                   ^ 8X  d   R# V P                   \        P                  ! 4       8w  d   V P                  P	                  R4       RV n        ^ V n         V P                  P                  V n        \        P                  R V P                  e0   V P                  P                  V P                  P                  4       \        P                  ! RV P                  ,          4       R# R# )r   NzMaster has been promoted.r   rL   r   )r-   r!   getppidr%   rs   r.   rE   rb   r"   r*   renamer   r   rA   s   &r   r   Arbiter.maybe_promote_master`  s    ??a??bjjl*HHMM56'DDO!XX//DN

>*||'##DHH$4$45}t~~=> +r>   c                P    V P                   P                  V P                  4       R# )z Wake up the arbiter's main loop.N)r(   r   WAKEUP_REQUESTrA   s   &r   wakeupArbiter.wakeupq  s    !!$"5"56r>   Nc                   V P                  4        V P                  4        V^ 8X  d   V P                  P                  MV P                  P                  pV! RV P
                  4       Ve
   V! RV4       V P                  e   V P                  P                  4        V P                  P                  V 4       \        P                  ! V4       R# )zhalt arbiter zShutting down: %sNz
Reason: %s)_stop_control_serverr   r%   rs   r   r.   r*   r   rE   on_exitr5   r   )r:   r   r   log_funcs   &&& r   r   Arbiter.haltu  s     	!!#		$/1$4488==$((..$d&6&67\6*<<#LL!r>   c                   . p V P                   P                  RVR7      pW0P                  8w  d   VP                  V4         V P                   P	                  4       pW0P                  8w  d   VP                  V4       K?  KA    \
        P                   d     T# i ; i  \
        P                   d     T# \         d    \        P                  ! 4         T# i ; i)zMWait for signals with timeout.
Returns a list of signals that were received.
T)blockra   )
r(   rv   r   r   
get_nowaitr&   Emptyr   r5   r   )r:   ra   signalsr   s   &&  r   r   Arbiter.wait_for_signals  s    
 	..$$4$AC)))s#..335C111s+ 2{{ 
 {{ 	  ! 	HHJ	sA   ?B ;B ?B BB BB C7C CCc                   V P                   V P                  u;8H  ;'       d    ^ 8H  Mu ;'       d5    V P                  '       * ;'       d    V P                  P                  '       * p\
        P                  ! V P                  V4       . V n        \        P                  pV'       g   \        P                  p\        P                  ! 4       V P                  P                  ,           pV P                  '       d   V P                  V4       V P                  V4       V'       * pV P                   '       g   V P                  '       Ed&   \        P                  ! 4       V8  Ed   V'       g    V P"                  P%                  4       pV\        P&                  \        P                  39   d   V P(                  P+                  R4       RpV P                  \        P                  4       V P                  '       d    V P                  \        P                  4       \        P                  ! 4       R,           pV P/                  4        V P1                  4        \        P2                  ! R4       EKJ  V P                  \        P4                  4       V P                  '       d    V P                  \        P4                  4       V P/                  4        V P1                  4        R#   \,         d     Li ; i)zStop workers

:attr graceful: boolean, If True (the default) workers will be
killed gracefully  (ie. trying to wait for the current connection)
zQuick shutdown requestedT       @皙?N)r,   r-   r   rE   r   r   close_socketsr|   r   r   SIGQUITrt   graceful_timeoutr/   r   r   WORKERSr(   r   SIGINTr%   rs   r   r   r   sleepSIGKILL)r:   gracefulr   r   limitquick_shutdownpending_sigs   &&     r   r   Arbiter.stop  s    OOt33!3 ( (LL ( (HH''' 	
 	4>>62nn..C		dhh777 !!!##C( 	#%|||t555499;;N!"&..";";"=K"v}}fnn&EE&@A)-))&..9111 33FNNC $		c 1 ##%JJsO&..)!!!##FNN3! ! s   +BK 8;K K,+K,c                   V P                   ^ 8w  d   V P                  P                  R4       R# V P                  ^ 8w  d   V P                  P                  R4       R# \        P
                  ! 4       p\        P                  ! 4       V n         V P                   ^ 8w  d   R# V P                  P                  V 4       V P                  P                  P                  4       p\        V4      VR&   V P                  '       dD   \        \        P
                  ! 4       4      VR&   \        \        V P                  4      4      VR&   M%RP                  R V P                   4       4      VR	&   \        P                   ! V P"                  R
,          4       \        P$                  ! V P"                  ^ ,          V P"                  R,          V4       R# )z)Relaunch the master and workers.
        z"USR2 signal ignored. Child exists.Nz#USR2 signal ignored. Parent exists.rL   
LISTEN_PID
LISTEN_FDSrp   c              3   T   "   T F  p\        VP                  4       4      x  K   	  R # 5ir@   )r   fileno)r   r   s   & r   r   !Arbiter.reexec.<locals>.<genexpr>  s!      .=-;cCJJL!!^s   &(ro   r    r   )r,   r%   warningr-   r!   rw   forkrE   pre_execenv_origcopyr   r   lenr|   rd   chdirr9   execvpe)r:   r-   r"   s   &  r   r   Arbiter.reexec  s<    ??aHHAB??aHHBCYY[
'')??a$((##((*"%j/<<<$'		$4GL!$'DNN(;$<GL!%(XX .=-1^^.= &=GM" 	&' 	

4>>!$dnnV&<gFr>   c                T   V P                   R ;;,          ^,          uu&   V P                  P                  pV P                  P                   F_  pW P                  P                  9   d1   V P                  P                  V,          \
        P                  V&   KM   \
        P                  V Ka  	  V P                  P                  4        V P                  V P                  4       V P                  P                  4        WP                  P                  8w  d   V P                   F  pVP                  4        K  	  \        P                   ! V P                  V P                  4      V n        RP#                  V P                   Uu. uF  p\%        V4      NK  	  up4      pV P                  P'                  RV4       V P                  P)                  V 4       V P*                  e   V P*                  P-                  4        V P                  P*                  eJ   \/        V P                  P*                  4      V n        V P*                  P1                  V P2                  4       \4        P6                  ! RV P8                  ,          4       V P:                  p\=        V P                  P>                  4       F  pV PA                  4        K  	  V PC                  4        \D        PF                  ! 4       V P                  PH                  ,           p\D        PF                  ! 4       V8  do   V PJ                  '       g   R# \M        R V PJ                  PO                  4        4       4      pW8  d   R# V PQ                  4        \D        PR                  ! R4       K  R#   \         d     EKU  i ; iu upi )r   rp   zListening at: %sNr   c              3   8   "   T F  qP                   x  K  	  R # 5ir@   age)r   ws   & r   r   !Arbiter.reload.<locals>.<genexpr>:  s     >(=1(=s   r  )*r3   rE   r^   rh   r  r!   r"   KeyErrorr;   r   r)   r%   r\   r|   closer   r   rd   r   rs   	on_reloadr*   r   r   ry   rx   r   r   rb   r+   r~   r_   spawn_workerr   rt   	monotonicr  r	  minvaluesr   r  )	r:   old_addressrk   r   r   last_worker_ager   deadlineoldests	   &        r   r   Arbiter.reload  s   I!#hh&& AHH%%% !% 1 1! 4

1

1  	

488 	 ((***~~		 & "00488DDNHH$..%I.3c#h.%IJMHHMM,m< 	4  <<#LL! 88'"488#3#34DLLL) 	=4>>9: // txx''(A ) 	 >>#dhh&?&??nn)<<<>(;(;(=>>F'JJsO *_   " &Js   NN%N"!N"c                6   V P                   '       g   R# \        V P                  P                  4       4      pV F  w  r# \        P
                  ! 4       VP                  P                  4       ,
          V P                   8:  d   KK   TP                  '       gF   T P                  P                  RT4       RTn
        T P                  T\        P                  4       K  T P                  T\        P                   4       K  	  R#   \        \        3 d     K  i ; i)z!Kill unused/idle workers
        NzWORKER TIMEOUT (pid:%s)T)ra   listr	  rg   rt   r+  tmplast_updateOSError
ValueErrorabortedr%   criticalkill_workerr   SIGABRTr  )r:   r_   rx   workers   &   r   r   Arbiter.murder_workers@  s     |||t||))+,$MS>>#fjj&<&<&>>$,,N O
 >>>!!";SA!%  fnn5  fnn5 % Z( s    ADDDc                :     \         P                  ! R\         P                  4      w  rV'       g   R# V P                  V8X  d
   ^ V n        KL  Rp\         P                  ! V4      '       d   \         P
                  ! V4      pM\         P                  ! V4      '       d   \         P                  ! V4      p \        P                  ! V4      P                  pRP                  W4      pV\        P                  8X  d&   VR,          pV P                  P                  V4       MLV\        P                   8X  d   V P                  P#                  V4       MV P                  P%                  V4       Ve$   V^ 8w  d   V P                  P                  RW4       W0P&                  8X  d   Rp\)        WpP&                  4      hW0P*                  8X  d   Rp\)        WpP*                  4      hV P,                  P/                  VR4      pV'       g   EK  VP0                  P3                  4        V P4                  P7                  W4       EK?    \         d    RP                  T4      p ELi ; i  \8         d,   p	T	P:                  \:        P<                  8w  d   h  Rp	?	R# Rp	?	ii ; i)	z/Reap workers to avoid zombie processes
        Nz	signal {}zWorker (pid:{}) was sent {}!z Perhaps out of memory?z$Worker (pid:%s) exited with code %s.zWorker failed to boot.zApp failed to load.r   )r!   waitpidWNOHANGr,   	WIFEXITEDWEXITSTATUSWIFSIGNALEDWTERMSIGr   Signalsr   r8  rO   r  r%   r   r   rs   r  WORKER_BOOT_ERRORr   APP_LOAD_ERRORr	  r   r5  r(  rE   
child_exitr7  errnoECHILD)
r:   wpidstatusexitcoder   sig_namemsgr   r=  es
   &         r   r   Arbiter.reap_workersU  s   4	!zz"bjj9??d*&'DO
  $H||F++#%>>&#9// kk&1?'-~~c':'?'?H =CC , &..0#<<C HHNN3/ FNN2 HHMM#. !HH,,S1+A'M'+7  #9#99!9(1G1GHH#6#66!6(1D1DEE!\\--dD9F! JJ$$&HH''5?  * ?'2'9'9#'>H?@  	ww%,,& '	sS   0I$ 7I$ ,2I$ I$ 6 I D/I$ ;I$ I!I$  I!!I$ $J/ JJc           	        \        V P                  4      V P                  8  d   V P                  4        V P                  P	                  4       p\        VR R7      p\        V4      V P                  8  d6   VP                  ^ 4      w  r#V P                  V\        P                  4       KO  \        V4      pV P                  V8w  d9   W@n
        V P                  P                  RP                  V4      RRRVRR/R	7       V P                  P                  '       dZ   \!        R
 V P"                   4       4      pV^ 8  d5   V P                  P                  RP                  V4      RRRVRR/R	7       R# R# R# )zCMaintain the number of workers by spawning or killing
as required.
c                 (    V ^,          P                   # rS   r#  )r%  s   &r   rW   (Arbiter.manage_workers.<locals>.<lambda>  s    !r>   rY   z{0} workersmetriczgunicorn.workersrG   mtypegauge)extrac              3   X   "   T F   pVP                   ! 4       ;'       g    ^ x  K"  	  R# 5i)r   N)get_backlog)r   r   s   & r   r   )Arbiter.manage_workers.<locals>.<genexpr>  s+      6&4d **,111&4s   **zsocket backlog: {0}zgunicorn.backlog	histogramN)r  r	  r`   spawn_workersrg   re   r   r;  r   r   r$   r%   rc   rO   rE   enable_backlog_metricsumr|   )r:   r_   rx   r   active_worker_countbacklogs   &     r   r   Arbiter.manage_workers  sK   
 t||t/// ,,$$&&89'lT---{{1~HSS&..1!'l004GG4G1HHNN=//0CD"*,>")+>")7"4  5
 88))) 6&*nn6 6G !|4;;GD&.0B&-w&-{&<  = 	 *r>   c           	     b	   V ;P                   ^,          un         V P                  V P                   V P                  V P                  V P                  V P
                  R,          V P                  V P                  4      pV P                  P                  W4       \        P                  ! 4       pV^ 8w  d6   W!n        WP                  V&   V P                  R;;,          ^,          uu&   V# V P                  P                  4        F  pVP                  P                  4        K  	  \        P                   ! 4       Vn         \"        P$                  ! RV P&                  ,          4       V P                  P)                  RVP                  4       V P                  P*                  '       d1   \,        P.                  ! V P                  V P                  4      Vn        V P                  P3                  W4       VP5                  4        \6        P8                  ! ^ 4       T P                  P)                  RTP                  4        TP                  P                  4        T P                  PQ                  Y4       R
#   \:         d    h \<         d   pT P                  P?                  RRR7       \A        RT,          \6        PB                  R	7       \6        PB                  PE                  4        \6        P8                  ! T PF                  4        R
p?LR
p?i\H         d   pT P                  PK                  R4       \A        RT,          \6        PB                  R	7       \6        PB                  PE                  4        TPL                  '       g!   \6        P8                  ! T PN                  4       \6        P8                  ! R4        R
p?ELR
p?ii ; i  \H         d4    T P                  PS                  R\T        PV                  ! 4       4        R
# i ; i  T P                  P)                  RTP                  4        TP                  P                  4        T P                  PQ                  Y4       i   \H         d3    T P                  PS                  R\T        PV                  ! 4       4        i i ; i; i)rT   r  r   zworker [%s]zBooting worker with pid: %sz'Exception while loading the applicationTr   z%s)fileNzException in worker processzWorker exiting (pid: %s)z Exception during worker exit:
%sr   ),r+   r]   rx   r|   r;   ra   rE   r%   pre_forkr!   r  r	  r3   r-  r5  r(  rw   r   r   rb   rs   r   r   r   sockets	post_forkinit_processr5   r   r   r   rc   printstderrflushrH  r   	exceptionbootedrG  worker_exitr  	traceback
format_exc)r:   r=  rx   siblingrQ  s   &    r   r*  Arbiter.spawn_worker  s   1""4??DHHdnn#'88T\\C-?#'88TXX7 	$'ggi!8J &LLKK)*a/*J ||**,GKK - YY[
	9}t~~=>HHMM7Dxx"""!%!4!4TXXtxx!HHHt,!HHQK" HHMM4fjjA9

  "$$T2'  	 	*HHNND$(  *$(,JJHHT(()) 	HH<=$(,JJ===//0HHRLL	  9  !D!*!5!5!799	 HHMM4fjjA9

  "$$T2 9  !D!*!5!5!799s    CI8 5O 8OOA=LP OOB#OP OP :PP'R.85Q.-R..:R+(R.*R++R.c                    \        V P                  \        V P                  4      ,
          4       FC  pV P	                  4        \
        P                  ! R\        P                  ! 4       ,          4       KE  	  R# )ziSpawn new workers as needed.

This is where a worker process leaves the main loop
of the master process.
r  N)r~   r`   r  r	  r*  rt   r  random)r:   r   s   & r   r^  Arbiter.spawn_workers  sJ     t''#dll*;;<AJJsV]]_,- =r>   c                    \        V P                  P                  4       4      pV F  pV P                  W14       K  	  R# )zFKill all workers with the signal `sig`
:attr sig: `signal.SIG*` value
N)r4  r	  keysr;  )r:   r   worker_pidsrx   s   &&  r   r   Arbiter.kill_workers  s3    
 4<<,,./CS& r>   c                    \         P                  ! W4       V\        P                  \        P                  39   d"   V P
                  R;;,          ^,          uu&   R# R#   \         d   pTP                  \        P                  8X  dt    T P                  P                  T4      pTP                  P                  4        T P                  P                  Y4        Rp?R#   \        \        3 d	      Rp?R# i ; ih Rp?ii ; i)zJKill a worker

:attr pid: int, worker pid
:attr sig: `signal.SIG*` value
 r   N)r!   killr   r   r  r3   r7  rJ  ESRCHr	  r   r5  r(  rE   ro  r'  )r:   rx   r   rQ  r=  s   &&&  r   r;  Arbiter.kill_worker  s    	GGCv~~v~~66,-2- 7 		ww%++%!\\--c2FJJ$$&HH((6 '* 		s7   AA   D+C>AC!!C:2C>9C::C>>Dc                    ^ RI pV P                  P                  RR4      P                  RR4      p\        P                  P                  VP                  4       RV R24      # )a	  Get the well-known PID file path for orphan detection.

Uses self.proc_name (not self.cfg.proc_name) so that during USR2
the new master gets a different PID file path ("myapp.2" vs "myapp").
This prevents the old dirty arbiter from removing the new one's PID file.
N/r    zgunicorn-dirty-z.pid)tempfilerb   replacer!   pathrd   
gettempdir)r:   r  	safe_names   &  r   _get_dirty_pidfile_pathArbiter._get_dirty_pidfile_path  sQ     	NN**34<<S#F	ww||H//1_YKt3TUUr>   c                t   V P                   ^ 8w  d   R# V P                  4       p\        P                  P	                  V4      '       g   R#  \        V4      ;_uu_ 4       p\        VP                  4       P                  4       4      pRRR4       \        P                  ! X^ 4       V P                  P                  RV4       \        P                  ! V\        P                  4       \        ^
4       F1  p\        P                   ! R4        \        P                  ! V^ 4       K3  	  \        P                  ! V\        P$                  4         \        P*                  ! V4       R#   + '       g   i     L; i  \"         d      K;  i ; i  \&        \(        \"        3 d     LWi ; i  \"         d     R# i ; i)zuKill any orphaned dirty arbiter from a previous crash.

Only runs on fresh start (master_pid == 0), not during USR2.
Nz(Killing orphaned dirty arbiter (pid: %s)r  )r-   r  r!   r  existsopenru   readstripr|  r%   r  r   r   r~   rt   r  r7  r  r8  IOErrorr   )r:   r*   fold_pidr   s   &    r   _cleanup_orphaned_dirty_arbiter'Arbiter._cleanup_orphaned_dirty_arbiter  s3    ??a..0ww~~g&&	g!affhnn./  GGGQHHGQGGGV^^,2Y

3GGGQ'  0
	IIg-    GW- 		  		sa   F (E&BF E9#)F F( &E6	1F 9F	F F		F F%$F%(F76F7c                   ^ RI HpHp V P                  '       d   R# V P	                  4        V P                  4       V n        V! V P                  V P                  V P                  R7      V n	        V P                  P                  p\        P                  ! 4       pV^ 8w  d@   W@n        V! V4       V\        P                  R&   V P                  P                  RWC4       V#  V P                  P                  4        \         P"                  ! ^ 4       R#   \$         d    h \&         d6    T P                  P)                  R4       \         P"                  ! R4        R# i ; i)z~Spawn the dirty arbiter process.

The dirty arbiter manages a separate pool of workers for
long-running, blocking operations.
)DirtyArbiterset_dirty_socket_pathN)r*   GUNICORN_DIRTY_SOCKETz%Spawned dirty arbiter (pid: %s) at %sz"Exception in dirty arbiter processr   )gunicorn.dirtyr  r  r/   r  r  r1   rE   r%   r0   socket_pathr!   r  r"   rs   r   r5   r   r   r   rm  )r:   r  r  r  rx   s   &    r   r   Arbiter.spawn_dirty_arbiterF  s    	G!!! 	,,. "99;)HHdhh&&
 ((44ggi!8%("!+.2=BJJ./HHMMA,J	""$HHQK 	 	HHCDHHRL	s   "0D E)2EEc                
   V P                   '       g   R#  \        P                  ! V P                   V4       R#   \         d?   pTP                  \        P
                  8X  d   ^ T n         RT n         Rp?R#  Rp?R# Rp?ii ; i)zDSend a signal to the dirty arbiter.

:attr sig: `signal.SIG*` value
N)r/   r!   r|  r7  rJ  r}  r0   )r:   r   rQ  s   && r   r   Arbiter.kill_dirty_arbitert  sd     %%%	*GGD**C0 	*ww%++%)*&%)"" &	*s   !9 B-A==Bc                   V P                   '       g   R#  \        P                  ! V P                   \        P                  4      w  rV'       g   R# \        P                  ! V4      '       dX   \        P
                  ! V4      pV^ 8w  d   V P                  P                  RW4       MkV P                  P                  RV4       MN\        P                  ! V4      '       d3   \        P                  ! V4      pV P                  P                  RW4       ^ V n         RV n        R#   \         d?   pTP                  \        P                  8X  d   ^ T n         RT n         Rp?R#  Rp?R# Rp?ii ; i)z9Reap the dirty arbiter process if it has exited.
        Nz*Dirty arbiter (pid:%s) exited with code %szDirty arbiter (pid:%s) exitedz*Dirty arbiter (pid:%s) killed by signal %s)r/   r!   r@  rA  rB  rC  r%   r   rs   rD  rE  r  r0   r7  rJ  rK  )r:   rL  rM  rN  r   rQ  s   &     r   r   Arbiter.reap_dirty_arbiter  s    %%%	*::d&<&<bjjILD||F##>>&1q=HHNN#O#'3 HHMM"A4H''kk&)  !M!%, &'D"!%D 	*ww%,,&)*&%)"" '	*s+   9D" D" -A2D"  A D" "E+--E&&E+c                    V P                   '       d   R# V P                  P                  ^ 8  dL   V P                  P                  '       d.   V P                  P                  R4       V P                  4        R# R# R# )zDMaintain the dirty arbiter process by respawning if needed.
        NzSpawning dirty arbiter...)r/   rE   r   r   r%   rs   r   rA   s   &r   r   Arbiter.manage_dirty_arbiter  sY     !!!88!!A%$((*=*=*=HHMM56$$& +>%r>   c                    V P                   P                  p\        P                  P	                  V4      '       g4   \        P                  P                  \        P                  ! 4       V4      pV# )z<Get the control socket path, making relative paths absolute.)rE   control_socketr!   r  isabsrd   r   r4   )r:   r  s   & r   _get_control_socket_path Arbiter._get_control_socket_path  sD    hh--ww}}[))'',,t{{}kBKr>   c                   V P                   P                  '       d   V P                  P                  R4       R# ^ RIHp V P                  4       pV P                   P                  p V! WV4      V n        V P                  P                  4        R#   \         d/   pT P                  P                  RT4       RT n         Rp?R# Rp?ii ; i)zoStart the control socket server.

The server runs in a background thread and accepts commands
via Unix socket.
zControl socket disabledN)ControlSocketServerz"Failed to start control socket: %s)rE   control_socket_disabler%   rc   gunicorn.ctl.serverr  r  control_socket_moder2   r   r   r  )r:   r  r  socket_moderQ  s   &    r   r   Arbiter._start_control_server  s     88***HHNN45 	<335hh22	(#6;$D    &&( 	(HHA1E#'D  	(s   '(B C
#CC
c                    V P                   '       d%    V P                   P                  4        RV n         R# R#   \         d'   pT P                  P	                  RT4        Rp?L7Rp?ii ; i)z(Stop the control socket server.
        z!Error stopping control server: %sN)r2   r   r   r%   rc   )r:   rQ  s   & r   r   Arbiter._stop_control_server  sa     G$$))+ $(D     GBAFFGs   9 A*A%%A*)r|   r(   r9   r2   r$   r#   r3   r^   r;   rE   r0   r/   r1   r%   r.   r-   r`   rx   r*   rb   r,   r   ra   r+   r]   )Nr   )r   )T)A__name__
__module____qualname____firstlineno____doc__rG  rH  r9   r|   r	  r   NSIGr   r   r   r   dictdirr   r<   rB   rI   propertyr`   r)   r   r{   r   r   r   
handle_cldr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r*  r^  r   r;  r  r  r   r   r   r   r  r   r   __static_attributes____classdictcell__)x__classdict__s   0@r   r   r      s      NIIG [[N FKKMOM1 vw{+MOG >A&k I
-
^!: +-=>K@:"x
8'.`'" J3

	4??"7"24"l GDGR6*8t=@29h
.'6	V&P,\* *>	'(4	( 	(KOs    Dr   )rJ  r!   r&   ru  r   r5   rt   rp  r   gunicorn.errorsr   r   gunicorn.pidfiler   gunicornr   r   r   r	   r
   r   rU   r>   r   <module>r     s=     	    
    6 $ ( ( 1
E( E(r>   