File: //home/arjun/projects/env/lib/python3.10/site-packages/gunicorn/__pycache__/pidfile.cpython-310.pyc
o
%we? � @ s, d dl Z d dlZd dlZG dd� de�ZdS )� Nc @ s8 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� ZdS )
�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 C s || _ d | _d S �N)�fname�pid)�selfr � r �I/home/arjun/projects/env/lib/python3.10/site-packages/gunicorn/pidfile.py�__init__ s
zPidfile.__init__c C s� | � � }|r|t�� krd S d}t||| jf ��|| _tj�| j�}|r1tj�|�s1td| ��t j
|d�\}}t�|d| j �d�� | jrPt�
|| j� n|| _t�|� t�| jd� d S )Nz5Already running on PID %s (or pid file '%s' is stale)z'%s doesn't exist. Can't create pidfile.)�dirz%s
zutf-8i� )�validate�os�getpid�RuntimeErrorr r �path�dirname�isdir�tempfile�mkstemp�write�encode�rename�close�chmod)r r �oldpid�msg�fdir�fdr r r r �create s"