
    ޕg	                     0    d dl Z d dlZd dlZ G d d      Zy)    Nc                   .    e Zd ZdZd Zd Zd Zd Zd Zy)Pidfilez    Manage a PID file. If a specific name is provided
    it and '"%s.oldpid" % name' will be used. Otherwise
    we create a temp file using os.mkstemp.
    c                      || _         d | _        y N)fnamepid)selfr   s     O/var/www/html/AdoubleTech/venv/lib/python3.12/site-packages/gunicorn/pidfile.py__init__zPidfile.__init__   s    
    c                    | j                         }|r4|t        j                         k(  ry d}t        ||| j                  fz        || _        t        j                  j                  | j                        }|r-t        j                  j                  |      st        d|z        t        j                  |      \  }}t        j                  |d| j
                  z  j                  d             | j                  r!t        j                  || j                         n|| _        t        j                  |       t        j                  | j                  d       y )Nz5Already running on PID %s (or pid file '%s' is stale)z'%s doesn't exist. Can't create pidfile.)dirz%s
zutf-8i  )validateosgetpidRuntimeErrorr   r   pathdirnameisdirtempfilemkstempwriteencoderenameclosechmod)r	   r   oldpidmsgfdirfdr   s          r
   createzPidfile.create   s    $ICsfdjj%99:: wwtzz*d+H4OPP$$.	E
ftxx'//89::IIeTZZ(DJ
 	S!r   c                 h    | j                          || _        | j                  | j                         y r   )unlinkr   r!   r   )r	   r   s     r
   r   zPidfile.rename.   s"    
DHHr   c                    	 t        | j                        5 }t        |j                         xs d      }ddd       | j                  k(  r t        j                  | j                         yy# 1 sw Y   9xY w# t        $ r Y yw xY w)z delete pidfiler   N)openr   intreadr   r   r#   	Exception)r	   fpid1s      r
   r#   zPidfile.unlink3   st    	djj! *Q1668=q)* txx		$**%  * *
  		s'   A9 A-6A9 -A62A9 9	BBc                 T   | j                   sy	 t        | j                         5 }	 t        |j                               }	 t        j                  |d       |cddd       S # t        $ r Y ddd       yw xY w# t        $ rc}|j                  d   t        j                  k(  r|cY d}~cddd       S |j                  d   t        j                  k(  rY d}~ddd       y d}~ww xY w# 1 sw Y   yxY w# t        $ r+}|j                  d   t        j                  k(  rY d}~y d}~ww xY w)z- Validate pidfile and make it stale if neededNr   )r   r%   r&   r'   
ValueErrorr   killOSErrorargserrnoEPERMESRCHENOENT)r	   r)   wpides       r
   r   zPidfile.validate>   s   zz	djj! Qqvvx=DGGD!$  " 	   vvayEKK/#  vvayEKK/     	vvayELL(	s   C3 C'A! A8	C3 !	A5*C'+C3 4A55C'8	C$!C"C$#C''	C3 1 CC'C3 CC$$C''C0,C3 0C3 3	D'< D"!D""D'N)	__name__
__module____qualname____doc__r   r!   r   r#   r    r   r
   r   r   
   s     "2
	r   r   )r0   r   r   r   r:   r   r
   <module>r;      s   
  	 K Kr   