+
    ΂Fj}                         ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RItRtRt	Rt
RtRtRtRt^ZtR	 tR
 tR tR tR tR tRR ltR tR tR tR tR tR t]R8X  d   ]! ]! 4       4      hR# )    NzC:\TripServer\admin_server.pyz@C:\Users\User\AppData\Local\Programs\Python\Python314\python.exezC:\TripServeri@  zhttp://127.0.0.1:8000/ping.jsonz%C:\TripServer\tripserver_watchdog.logz+C:\TripServer\tripserver_watchdog_state.txtc                     \         P                  ! \         P                  P                  \        4      R R7       \        \        RRR7      ;_uu_ 4       pVP                  \        P                  ! R4      R,           \        V 4      ,           R,           4       RRR4       R#   + '       g   i     R# ; i  \         d     R# i ; i)	Texist_okautf-8encoding%Y-%m-%d %H:%M:%Sz | watchdog-v28 | 
N)osmakedirspathdirnamelog_pathopenwritetimestrftimestr	Exception)messagefhs   & *C:\TripServer\tripserver_admin_watchdog.pylogr      s    
BGGOOH-=(C'22bHHT]]#67:NNQTU\Q]]`dde 3222 s1   AB7 AB#B7 #B4	.B7 4B7 7CCc                  8    \        \        R RR7      P                  4       P                  4       p V '       g   / #  \        P
                  ! V 4      p\        V\        4      '       d   V# / #   \         d    R\        T 4      /u # i ; i  \         d    / u # i ; i)rr   r   
last_start)
r   
state_pathreadstripjsonloads
isinstancedictr   float)rawdatas     r   
load_stater(      s    
:sW5::<BBDI	.::c?D%dD1149r9 	. %*--	. 	s4   7B	 -A+ )A+ +BB	 BB	 	BBc                 8    \         P                  ! \         P                  P                  \        4      R R7       \        \        RRR7      ;_uu_ 4       p\        P                  ! W4       RRR4       R#   + '       g   i     R# ; i  \         d     R# i ; i)Tr   wr   r   N)	r   r   r   r   r   r   r!   dumpr   )stater   s   & r   
save_stater-   (   s_    
BGGOOJ/$?*cG44IIe  5444 s0   AB
 A6,B
 6B	B
 B
 
BBc                       \         P                  ! R \        \        4      3RR7      ;_uu_ 4         RRR4       R#   + '       g   i     R# ; i  \         d     R# i ; i)z	127.0.0.1g       @timeoutNTF)socketcreate_connectionint
admin_portr        r   	port_openr7   0   sG    %%{C
O&DcRR SRRR s+   /A =A A	A A A A c                     . p \         P                  R 8w  d   V #  \        P                  ! . R
ORRR^
R7      pVP                  ;'       g    RR,           VP
                  ;'       g    R,           pR\        \        4      ,           pVP                  4        Fp  pW49  g   RVP                  4       9  d   K   VP                  4       pV'       g   K:   \        VR,          4      pV'       d   W`9  d   V P                  V4       Kn  Kp  Kr  	  V #   \         d     K  i ; i  \         d'   p\        R\        T4      ,           4        R	p?T # R	p?ii ; i)ntTFcapture_outputtextshellr0    r   :listenznetstat failed: N)netstatz-anoz-ptcp)r   name
subprocessrunstdoutstderrr   r4   
splitlineslowersplitr3   appendr   r   repr)pidscpoutmarkerlinepartspidexcs           r   pids_on_portrV   7   s   D	ww$,^^<TX\disuvyyB$&"))//r:s:&NN$D!XTZZ\%AJJLEueBi.CsC(  /s % K	 !  ,c*++K,sH   /D D 'A$D 1DD DD DD E)E

Ec                 ~    \        V 4      p T ^ 8:  g   T \        P                  ! 4       8X  dH   \	        R\        T 4      ,           R,           \        \        P                  ! 4       4      ,           4       R #  \        P                  R8X  d   \        P                  ! RR\        T 4      R.RRR ^R7      p\	        R	\        T 4      ,           R
,           \        TP                  4      ,           R,           TP                  ;'       g    TP                  ;'       g    RP                  4       R,          ,           4       TP                  ^ 8H  # \        P                  ! T ^	4       R#   \         d     R # i ; i  \         d>   p\	        R\        T 4      ,           R,           \        T4      ,           4        Rp?R # Rp?ii ; i)Fzskip killing pid=z self=r9   taskkillz/PIDz/FTr:   ztaskkill-port-owner pid=z rc=z out=r>   Ni  Nzkill port owner failed pid=z err=N)r3   r   r   getpidr   r   rD   rE   rF   
returncoderG   rH   r    killrM   )rT   rO   rU   s   &  r   kill_port_ownerr]   N   sf   #h ax3"))+%#c(*X5BIIK8HHI	77d?VSXt DUY`dlq{}~B*SX5>R]]ASSV]]bdbkbkb~b~oqoxoxb~b~|~  bF  bF  bH  IM  bN  O  P==A%%
Q    )CH4w>cJKs6   E" 6B!E4 0E4 	E4 "E10E14F<?2F77F<c                     \         P                   ! 4       V ,           p\         P                   ! 4       V8  d+   \        4       '       g   R # \         P                  ! R4       KD  \        4       '       * # )Tg333333?)r   r7   sleep)r0   deadlines   & r   wait_port_closedra   c   s?    yy{W$H
))+
 {{

3{?r6   c                      \         P                  P                  \        R R/R7      p \         P                  P	                  V RR7      ;_uu_ 4       pVP                  R4      P                  RRR7      pR	R	R	4       \        P                  ! X4      p\        VP                  R
4      4      VP                  R
4      '       d   R3# VR,          3#   + '       g   i     Lc; i  \         d   pR\        T4      3u R	p?# R	p?ii ; i)Acceptzapplication/json)headersg      @r/   i    r   replace)errorsNokOKrY   F)urllibrequestRequest
health_urlurlopenr   decoder!   r"   boolgetr   rM   )reqrespr&   r'   rU   s        r   	health_okrs   k   s     nn$$Z(DV9W$X^^##C#55))D/(((CC 6zz#DHHTN#TXXd^^TJJTJJ 65   d3i s=   AC# #C5AC# 	C# C 	C# #D.D :D Dc                      \        V P                  R 4      ;'       g    ^ 4      p\        P                  ! 4       V,
          \        \        4      8  #   \         d     R# i ; i)r   F)r%   rp   r   cooldown_secondsr   )r,   lasts   & r   recently_startedrw   u   sP    UYY|,112		d"e,<&=== s   A 2A A! A!c                 V    \         P                   ! 4       V R &   ^ V R&   \        V 4       R# )r   failure_countN)r   r-   )r,   s   &r   mark_startedrz   |   s$    ))+E,E/ur6   c                       ^ RI p V P                  \        RR7       R#   \         d   pR\	        T4      3u Rp?# Rp?ii ; i)r   NT)doraiseF)Trh   )
py_compilecompilescript_pathr   rM   )r}   rU   s     r   script_compilesr      sB     ;5  d3i s    A<AAc                    ^ p\         P                  R8X  d(   \        \        R^ 4      \        \        R^ 4      ,          p\         P                  P                  4       pVP                  RR4       \         P                  ! \         P                  P                  \        4      RR7       \        \        RRR	7      ;_uu_ 4       pVP                  \        P                  ! R
4      R,           \        ,           R,           4       VP!                  4        \        P"                  ! \$        \        .\&        \        P(                  TT\         P                  R8X  d   RMRV\         P                  R8g  VR7	      pVP                  \        P                  ! R
4      R,           \+        VP,                  4      ,           R,           4       RRR4       \/        V 4       R#   + '       g   i     L; i)r   r9   CREATE_NEW_PROCESS_GROUPDETACHED_PROCESSPYTHONIOENCODINGr   Tr   r   r   r
   z" | watchdog-v28 | starting admin: r   F)cwdstdinrG   rH   	close_fdscreationflagsstart_new_sessionenvz | watchdog-v28 | started pid=N)r   rD   getattrrE   environcopy
setdefaultr   r   r   r   r   r   r   r   r   flushPopen
python_exework_dirDEVNULLr   rT   rz   )r,   flagsr   log_fileprocs   &    r   launch_adminr      sF   E	ww$
$>BWZYkmnEoo
**//
CNN%w/KK)D9	hg	.	.(t}}%89<``cnnquuv%$$ "4uT!ww$

 	t}}%89<\\_bcgckck_llosst 
/  
/	.s   C?GG&	c                  .   \        4       p \        4       w  rV'       d*   V P                  R 4      '       d   ^ V R &   \        V 4       ^ # \	        V P                  R 4      ;'       g    ^ 4      ^,           pW0R &   \        V 4       \        4       p\        R\        V4      ,           R,           \        V4      ,           R,           \        V4      ,           4       \        V 4      '       d   \        R4       ^# V'       di   \        4       pV^8  d   \        R\        V4      ,           4       ^# \        R\        V4      ,           4       V F  p\        V4       K  	  \        ^4       \        P                  P                  \        4      '       g   \        R\        ,           4       ^# \!        4       w  rxV'       g   \        R\        V4      ,           4       ^#  \#        V 4       ^
#   \$         d'   p	\        R	\'        T	4      ,           4        R
p	?	^# R
p	?	ii ; i)ry   zhealth failed count=z port_open=z info=z)restart cooldown active; skip this minutezRport is open but health failed; waiting for second failure before hard kill. pids=z8port open + repeated health failure; killing stuck pids=zadmin script not found: z2admin script does not compile; not starting. info=zfailed to launch admin: N)r(   rs   rp   r-   r3   r7   r   r   rw   rV   r]   ra   r   r   existsr   r   r   r   rM   )
r,   rg   info
fail_countis_port_openrN   rT   
ok_compilecompile_inforU   s
             r   mainr      s   LE{HB	99_%%%&E/"uUYY/44159J'/u;LZ0=@3|CTTW__befjbkkl78~>dgjkogppqFTRSCC  77>>+&&&45.0J@3|CTTUU &c23s   G# #H.HH__main__)   )r   sysr   r1   rE   urllib.requestri   r!   r   r   r   r4   rl   r   r   ru   r   r(   r-   r7   rV   r]   ra   rs   rw   rz   r   r   r   __name__
SystemExitr5   r6   r   <module>r      s    	 
     /W

.
4<
 .* 
 0%N z
TV
 r6   