GOOD SHELL MAS BOY
Server: Apache/2.4.52 (Ubuntu)
System: Linux vmi1836763.contaboserver.net 5.15.0-130-generic #140-Ubuntu SMP Wed Dec 18 17:59:53 UTC 2024 x86_64
User: www-data (33)
PHP: 8.4.10
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/supervisor/__pycache__/options.cpython-310.pyc
o

F��^�U�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZddlmZddlmZmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZddlm Z dd
lm!Z!ddlm"Z"ddlm#Z#ddlm$Z$ddlm%Z%ddlm&Z&ddlm'Z'ddlm(Z(ddlm)Z)ddlm*Z*ddlm+Z+ddlm,Z,ddlm-Z-ddlm.Z.ddlm/Z/ddlm0Z0ddlm1Z1ddlm2Z2ddlm3Z3dd l4m5Z5dd!l4m6Z6dd"l4m7Z7dd#l4m8Z8d$d%�Z9e9�Z:d&d'�Z;Gd(d)�d)�Z<Gd*d+�d+�Z=Gd,d-�d-e=�Z>Gd.d/�d/e=�Z?gZ@Gd0d1�d1ejA�ZBGd2d3�d3eC�ZDGd4d5�d5eD�ZEGd6d7�d7eE�ZFGd8d9�d9eE�ZGGd:d;�d;eD�ZHGd<d=�d=eD�ZIGd>d?�d?eH�ZJd@dA�ZKdBdC�ZLdDdE�ZMdaNdFdG�ZOdHdI�ZPGdJdK�dK�ZQdLdM�ZRdNdO�ZSdPdQ�ZTGdRdS�dSeU�ZVGdTdU�dUeV�ZWGdVdW�dWeV�ZXGdXdY�dYeV�ZYGdZd[�d[eV�ZZdS)\�N)�PY2)�ConfigParser)�as_bytes�	as_string)�	xmlrpclib)�StringIO)�
basestring)�asyncore_25)�process_or_group_name)�boolean)�integer)�name_to_uid)�gid_for_uid)�existing_dirpath)�	byte_size)�
signal_number)�list_of_exitcodes)�dict_of_key_value_pairs)�logfile_name)�list_of_strings)�
octal_type)�existing_directory)�
logging_level)�colon_separated_user_group)�inet_address)�InetStreamSocketConfig)�UnixStreamSocketConfig)�url)�	Automatic)�auto_restart)�profile_options)�loggers)�states)�xmlrpc)�pollercCs\tj�tj�t��}tj�|d�}t|d��}|����Wd�S1s'wYdS)Nzversion.txt�r)	�os�path�abspath�dirname�__file__�join�open�read�strip)�mydir�version_txt�f�r2�4/usr/lib/python3/dist-packages/supervisor/options.py�_read_version_txt9s

$�r4cCstj�tj�tj�|���S�N)r&r'�normpathr(�
expanduser)�vr2r2r3�normalize_path@sr9c@seZdZdS)�DummyN)�__name__�
__module__�__qualname__r2r2r2r3r:Csr:c@s�eZdZejZejZejZeZdZZ	ej
dZdZdZ
dZdZdZddd�Zdd�Zdd	�Zd
d�Z									d dd
�Zdd�Zd!dd�Zddd�Zdd�Zdd�Zd"dd�Zdd�Zdd�ZdS)#�OptionsNrTcCs�g|_g|_g|_i|_i|_i|_i|_i|_||_|�	dddd|j
�|�	dddd�tj�
tj�
tjd��}tj�|dd	�tj�|d	�d	d
ddg}||_i|_tj��D]\}}||jd
|<qXdS)znConstructor.

        Params:
        require_configfile -- whether we should fail on no config file.
        N�h�help�
configfilezc:zconfiguration=r�etczsupervisord.confzetc/supervisord.confz/etc/supervisord.confz /etc/supervisor/supervisord.confzENV_%s)�
names_list�
short_options�long_options�options_map�default_map�required_map�environ_map�attr_priorities�require_configfile�addr@r&r'r)�sys�argvr+�searchpaths�environ_expansions�environ�items)�selfrK�hererO�kr8r2r2r3�__init__Xs0��zOptions.__init__cCsLd}|jD]}tj�|�r|}nq|dur$|jr$|�dd�|j��|S)z=Return the name of the found config file or print usage/exit.NzjNo config file found at default paths (%s); use the -c option to specify a config file at a different path�, )rOr&r'�existsrK�usager+)rS�configr'r2r2r3�default_configfilexs
�
�zOptions.default_configfilecCs@|jd}|�d�dkr|�d|j�}|j�|�|�d�dS)zxPrint a long help message to stdout and exit(0).

        Occurrences of "%s" in are replaced by self.progname.
        �
z%srN)�doc�find�replace�progname�stdout�write�exit)rS�dummyr@r2r2r3r@�s

zOptions.helpcCs4|j�dt|��|j�d|j�|�d�dS)z2Print a brief error message to stderr and exit(2).z
Error: %s
zFor help, use %s -h
�N)�stderrrb�strr`rc�rS�msgr2r2r3rY�sz
Options.usagec
Cs�|dur0|durtd��|s|std��|r|�d�rtd��|r*|�d�r*td��|fdd�}|rF|rF|�d�|�d�krFtd||f��|r�|d	d
krRtd��|dd�|dd�}
}|d
vrgtd��d
|
}
|
|jvrvtd|
��||f|j|
<|j�|�|r�|d	d
kr�td��|}
|
ddkr�|
dd�}
d|
}
|
|jvr�td|
��||f|j|
<|j�|�|	r�||f|j|	<|r�t||�s�t||d�|j	�||f�|dur�||j
|<|r�||j|<dSdSdS)a�Add information about a configuration option.

        This can take several forms:

        add(name, confname)
            Configuration option 'confname' maps to attribute 'name'
        add(name, None, short, long)
            Command line option '-short' or '--long' maps to 'name'
        add(None, None, short, long, handler)
            Command line option calls handler
        add(name, None, short, long, handler)
            Assign handler return value to attribute 'name'

        In addition, one of the following keyword arguments may be given:

        default=...  -- if not None, the default value
        required=... -- if nonempty, an error message if no value provided
        flag=...     -- if not None, flag value for command line option
        env=...      -- if not None, name of environment variable that
                        overrides the configuration file or default
        Nz%use at most one of flag= and handler=z"flag= requires a command line flag�:�=cSs|Sr5r2)�arg�flagr2r2r3�<lambda>�szOptions.add.<locals>.<lambda>z&inconsistent short/long options: %r %rr�-z&short option should not start with '-'�)�rjz"short option should be 'x' or 'x:'zduplicate short option key '%s'z%long option should not start with '-'���z--zduplicate long option key '%s')�
ValueError�endswithrFrD�appendrErI�hasattr�setattrrCrGrH)rS�name�confname�short�long�handler�default�requiredrm�env�key�restr2r2r3rL�sb �



�zOptions.addcCs4|j�|d�}||krt|||�||j|<dSdS)Nrr)rJ�getrw)rS�attr�value�prio�currentr2r2r3�_set�s
�zOptions._setc
CsP|durtjdd�}|durtjd}|dur+z	ddl}|j}Wn	ty*Ynw||_||_g|_g|_zt	�	|d�
|j�|j�\|_|_Wnt	j
yc}z
|�t|��WYd}~nd}~ww|jrt|jst|�dt|j��|jD]M\}}|j|\}}	|	dur�z|	|�}Wnty�}
z|�d|||
f�WYd}
~
nd}
~
ww|r�|dur�t||�dur�|�d|�|�||d�qw|j��D]L}|j|\}}	|tjv�rtj|}|	du�rz|	|�}Wnt�y}
z|�d	|||
f�WYd}
~
nd}
~
ww|�r|du�r|�||d�q�|jdu�r"|��|_|��dS)
z�Realize a configuration.

        Optional arguments:

        args     -- the command line arguments, less the program name
                    (default is sys.argv[1:])

        doc      -- usage message (default is __main__.__doc__)
        Nrprrqz*positional arguments are not supported: %szinvalid value for %s %r: %sz"conflicting command line option %rrez'invalid environment value for %s %r: %s)rMrN�__main__�__doc__�	Exceptionr`r]�options�args�getoptr+rDrE�errorrYrg�positional_args_allowedrFrs�getattrr�rI�keysr&rQrAr[�process_config)
rSr�r]r`r��exc�optrlrxr|ri�envvarr�r2r2r3�realize�st

���� ���

����
zOptions.realizec	Cs�|jr|�|�|jD]%\}}|r0|�d�}|j}|D]
}|dur#nt||�}q|�||d�q|j��D]\}}t||�durGt	|||�q6|j
��D]\}}t||�dur]|�|�qMdS)z}Process configuration data structure.

        This includes reading config file if necessary, setting defaults etc.
        �.Nr)rA�process_config_filerC�split�
configrootr�r�rGrRrwrHrY)	rS�do_usagerxry�parts�obj�partr��messager2r2r3r�6s*

��
��zOptions.process_configc
Cszt|jd�stj�tj�|j��|_z	|�|j�WdSty<}z|r-|�	t
|��nt|��WYd}~dSd}~ww)Nr-)rvrAr&r'r(r)rT�read_configrsrYrg)rSr�rir2r2r3r�Us���zOptions.process_config_filecCstj�|�Sr5)r&r'rX�rSr'r2r2r3rXc�zOptions.existsr%cCs
t||�Sr5)r,)rS�fn�moder2r2r3r,f�
zOptions.openc	Cs�g}|��D]X}|�|�sq|�dd�d}|�||d�}|dur)td||f��z|�|�}Wnty?td||f��wi}	|�|�D]}
|
|krU|�||
�|	|
<qG|�|||	f�q|S)Nrjrpz"section [%s] does not specify a %s�!%s cannot be resolved within [%s])	�sections�
startswithr��sanegetrs�import_spec�ImportErrorr�ru)rS�parser�factory_key�section_prefix�	factories�sectionrx�factory_spec�factory�extrasrUr2r2r3�get_pluginsis0
����zOptions.get_pluginscCs,tj�d|�}t|d�r|��S|�d�S)Nzx=�resolveF)�
pkg_resources�
EntryPoint�parservr��load)rS�spec�epr2r2r3r��s

zOptions.import_spec�T)	NNNNNNNNN)NNN)r%)r;r<r=rMrfrarc�warnings�uid�gidrNr`rA�	schemadirr�rTr�rVr[r@rYrLr�r�r�r�rXr,r�r�r2r2r2r3r>FsD

 

�T

F
r>c@seZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZdZejjZdd�Zdd�Zdd	�Zd
d�Zdd
�Zdudd�Zdd�Zdd�Zdd�Z	dvdd�Z	dvdd�Zdd�Zdd�Z dd �Z!d!d"�Z"d#d$�Z#d%d&�Z$d'd(�Z%d)d*�Z&d+d,�Z'd-d.�Z(d/d0�Z)d1d2�Z*d3d4�Z+d5d6�Z,d7d8�Z-d9d:�Z.d;d<�Z/d=d>�Z0d?d@�Z1dAdB�Z2dCdD�Z3dEdF�Z4dGdH�Z5dIdJ�Z6dKdL�Z7dMdN�Z8dOdP�Z9dQdR�Z:dSdT�Z;dUdV�Z<dWdX�Z=dYdZ�Z>d[d\�Z?d]d^�Z@d_d`�ZAdadb�ZBdcdd�ZCdedf�ZDdgdh�ZEdidj�ZFdkdl�ZGdmdn�ZHdudodp�ZIdqdr�ZJdsdt�ZKdS)w�
ServerOptionsNr2FcCs�t�|�t�|_t�|j_|�dddd|j�|jddddddd�|�d	d
dd�|jd
dddtdd�|�ddddt�|jddddt	dd�|jddddt
d d�|jd!d"d#d$td%d�|jd&d'd(d)td*d�|jd+d,d-d.t	d/d�|jd0d1d2d3t
d4d�|jd5d6d7d8tt��d�|jd9d:d;d<td=d�|jd>d?d@dAtdBd�|jdCdDdEdCddd�|jdFdGdHdFddd�|jdIdJd@dKtdd�|jdLdMdNdLddd�i|_g|_g|_g|_g|_t�|_t�|�|_dS)ONr8�version�nodaemonzsupervisord.nodaemon�nrpr�rmr}�userzsupervisord.user�u:zuser=�umaskzsupervisord.umaskzm:zumask=�022�r}�	directoryzsupervisord.directoryzd:z
directory=�logfilezsupervisord.logfilezl:zlogfile=�supervisord.log�logfile_maxbyteszsupervisord.logfile_maxbyteszy:zlogfile_maxbytes=i �logfile_backupszsupervisord.logfile_backupszz:zlogfile_backups=�
�loglevelzsupervisord.loglevelze:z	loglevel=�info�pidfilezsupervisord.pidfilezj:zpidfile=�supervisord.pid�
identifierzsupervisord.identifierzi:zidentifier=�
supervisor�childlogdirzsupervisord.childlogdirzq:zchildlogdir=�minfdszsupervisord.minfdsza:zminfds=��minprocszsupervisord.minprocsrqz	minprocs=���	nocleanupzsupervisord.nocleanuprU�
strip_ansizsupervisord.strip_ansi�tr zsupervisord.profile_optionszprofile_options=�silentzsupervisord.silent�s)r>rVr:r��supervisordrLr�rrrrrrrg�tempfile�
gettempdir�intr �
pidhistory�process_group_configs�parse_criticals�parse_warnings�parse_infos�SignalReceiver�signal_receiverr$�Poller�rSr2r2r3rV�sz

����������������zServerOptions.__init__cCs|j�dt�|�d�dS)z-Print version to stdout and exit(0).
        �%s
rN)rarb�VERSIONrc)rSrdr2r2r3r��szServerOptions.versioncOstj|i|��Sr5)r!�	getLogger�rSr��kwargsr2r2r3r���zServerOptions.getLoggercCs"t��dkr|j�d�t�|�S)NraSupervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.)r&�getuidr��warnr>r[r�r2r2r3r[�s
�
z ServerOptions.default_configfilec

OsRtj|g|�Ri|��|jj}|jdur<zt|j�}Wnty3}z|�|�WYd}~nd}~ww||_t	|�|_
|jsC|j|_|jrJ|j}n|j}t
|�|_|jrY|j}n|j}t
|�|_|j|_d|_|j|_}dd�|D�D]}	|	d}
d|
|_|jdur�dd�|D�D]}	|	d}|	d}|s�d}d	||f|_q�|j|_dS)
NcS�g|]}|dtjur|�qS��family)�socket�AF_UNIX��.0rZr2r2r3�
<listcomp>
��z)ServerOptions.realize.<locals>.<listcomp>�file�	unix://%scSr�r�)r��AF_INETr�r2r2r3r�r��host�port�	localhostzhttp://%s:%s)r>r�r�r�r�r
rsrYr�rr�r�r�r9r��rpcinterface_factories�	serverurl�server_configsr�)
rSrl�kwr�r�rir�r��sconfigsrZr'rrr2r2r3r��sH
��




zServerOptions.realizeTcCs"tj||d�|jjj}||_dS)N)r�)r>r�r�r�r�)rSr��newr2r2r3r�s

zServerOptions.process_configcsg|_g|_g|_|jj}d}t|d�s9|�|�std|��z
|�|d�}d}Wnt	t
fy8td|��wt��|j�_
z4zz��|�WntyW��|�YnwWntjyl}ztt|���d}~wwW|rt|��n|r||��wwt��}|j|d�}|�|j���d��r��|j���dd	�s�td
����dd	�}t||d�}|��}t|d�r�tj �!tj �"|j#��}nd
}|D]Q}	tj �$||	�}	t%�%|	�}
|
s�|j�&d|	�q�t'|
�D]3}|j�&d|�z��(|�Wntj�y
}ztt|���d}~ww��tj �"tj �!|���q�qȈ�)�}d|v�r'td��d|ji���fdd�}
t*|
dd��|_+t*|
dd��|_,|
dd�}|du�rQd|_-nt.|�|_-|
dd�|_/t0|
dd��|_1t2|
dd��|_3t4|
dd ��|_5t*|
d!d"��|_6t7|
d#d$��|_8t2|
d%d&��|_9|
d'd(�|_:t;|
d)d*��|_<t;|
d+d*��|_=t>�?�}t.|
d,|��|_@t;|
d-d*��|_At;|
d.d*��|_B|
d/d0�}t||d/�}tC|�|_D|�E�d1d2�|_F|�G��|_H|jHD]}|jID]}|jD�J�}|�|jD�||_D�q�q�|�K��|_Ld|_M|S)3NFr-�could not find config file %sr%T�could not read config file %s)rT�host_node_name�include�filesz5.ini file has [include] section, but no files settingz
include.filesrxr�z No file matches via include "%s"z'Included extra file "%s" during parsingr�z..ini file does not include supervisord sectionrTcs2|�di�}|���||d<�j||fi|��S�N�
expansions)r��update�
getdefault)r�r}r�r��common_expansionsr�r2r3r�ls
z&ServerOptions.read_config.<locals>.getr�r�r�r�r�r�r�r�r�r�r��50MBr�r�r�r�r�r�r�r�r��falser�r�r�r��environmentrqzsupervisor.rpcinterface_factoryz
rpcinterface:)Nr�r�r�r�r�rvrXrsr,�IOError�OSError�UnhosedConfigParserrPr�	read_file�AttributeError�readfpr�ParsingErrorrg�close�platform�noderTr�has_section�expand_here�
has_optionr��expandr�r&r'r)r(rxr+�globru�sortedr-r�rr�r�r�rr�rr�rr�rr�r�rr�r�r�rr�r�r�r�r�r�r�rrr�r�process_groups_from_parserr��process_configs�copy�server_configs_from_parserrr )rS�fpr��
need_close�whyr
rr�base�pattern�	filenames�filenamer�r�r��tempdir�environ_str�group�procrr2rr3r�%s�

��������
��

������






�



�zServerOptions.read_configc"s�g}���}g}d|ji���fdd�}|D]u}|�d�sqt|�dd�d�}t||dd��}t||dd	��}	g}
|D]D}d
|}d|}
||vrV|
|vrVtd||f��||vrf|
|vrftd
||f��||vrl|n|
}|�|�|�	�||t
�}|
�|�q<|�t|||	|
��q|D]0}|�d�r�||vr�q�t|�dd�d�}t||dd	��}	|�	�||t
�}|�t|||	|��q�|D]�}|�d�s�q�|�dd�d}t||dd��}	t||dd��}|dkr�td||f��||dd�}z|�
|�}Wnt�y
td||f��wdd�t||dd��D�}t|�}|�s%td|��ddlm}g}|D]}t||d�}|du�rDtd||f��|�|��q/t||dd ��}|�r\td!|��|�	�||t�}|�t|||	||||��q�|D]�}|�d"��r�||v�r��qtt|�dd�d�}t||dd	��}	d#|i}||d$d�}|du�r�d}nt|�}||d%d�}|du�r�t|�}|dk�s�|d&k�r�td'|��||d(d�}|du�r�zt|�}Wnt�y�td)|��w||d*d�}|du�rzt|�}Wnttf�ytd+|��w||d,d|d-�}|�std.|��z|�|||||�} Wnt�y?}!z
td/t|!�|f��d}!~!ww|�	�||t�}|�t|||	|| ���qt|��|S)0NrTcs4|�di�}|���||d<�j|||fi|��Sr�r�rr�)r�r�r}r�rrr2r3r��s
z5ServerOptions.process_groups_from_parser.<locals>.getzgroup:rjrp�programs�priority��z
program:%szfcgi-program:%sz-[%s] names unknown program or fcgi-program %sz>[%s] name %s is ambiguous (exists as program and fcgi-program)zprogram:zeventlistener:rr�buffer_sizer�z*[%s] section sets invalid buffer_size (%d)�result_handlerz&supervisor.dispatchers:default_handlerr�cSsg|]}|���qSr2)�upper)r��xr2r2r3r��sz<ServerOptions.process_groups_from_parser.<locals>.<listcomp>�eventsrqz&[%s] section requires an "events" liner)�
EventTypesz$Unknown event type %s in [%s] events�redirect_stderrrzx[%s] section sets redirect_stderr=true but this is not allowed because it will interfere with the eventlistener protocolz
fcgi-program:�program_namer��socket_backlog�zInvalid socket_backlog value %s�socket_ownerzInvalid socket_owner value %s�socket_modezInvalid socket_mode value %sr��rz%[%s] section requires a "socket" linez%s in [%s] socket)r�rTr�r
r�rrrsru�processes_from_section�
ProcessConfig�extend�ProcessGroupConfigr�r��set�supervisor.eventsrAr�r�EventListenerConfig�EventListenerPoolConfigr
rr�	TypeError�parse_fcgi_socketrg�FastCGIProcessConfig�FastCGIGroupConfig�sort)"rSr��groups�all_sections�homogeneous_excluder�r��
group_namer9r:�group_processes�program�program_section�fcgi_section�	processesrC�	pool_namer<r=�pool_event_namesrA�pool_events�pool_event_name�
pool_eventrB�fcgi_expansions�	proc_user�proc_uidrDrFrGr��
socket_config�er2rr3r)�s:


���
��

��
������
��
�
��


�
��
������
�
��z(ServerOptions.process_groups_from_parsercCs�|�d�r>|dd�}tj�|�std|��t|�}|dur0t��}|dur0||kr0|t|�f}|dur6d}t||||d�S|dusF|durJtd��t	�
d|�}|re|�d�}	t|�d	��}
t
|	|
|d
�Std|��)N�unix://�z+Unix socket path %s is not an absolute path�)�ownerr��backlogzQsocket_owner and socket_mode params should only be used with a Unix domain socketztcp://([^\s:]+):(\d+)$rpre)rmzBad socket format %s)r�r&r'�isabsrsr9r�rr�re�matchr6r�r)rS�sockrfrFrGrDr'r��mrrr2r2r3rRHs6
��
�
zServerOptions.parse_fcgi_socketc
CsNz	|�||||�WSty&}z|j�||j�}td|||f��d}~ww)Nz%s in section %r (file: %r))�_processes_from_sectionrs�section_to_filer�rA)rSr�r�rY�klassrhr3r2r2r3rIks����z$ServerOptions.processes_from_sectionc0	s�|durt}g}t|�dd�d�}t��}|j|||d����fdd�}t||dd��}	t||dd	��}
t||d
d��}t||dd��}t||d
d��}
t	||dd��}t||dd��}t||dd��}t||d|��}t
||dd��}t||dd��}t||dd��}t||dd��}||dddd�}t||d d��}t||d!d��}t||d"d��}t||d#d��}||d$d�}|r�|���
�d%kr�d}||d&d�}|dur�d}nt|�}||d'd�}|dur�t|�}t||d(d)dd��}|dkr�d*|vr�td+��|�r|�std,��t|||�D�]-} �}!|!�| |d-��|!�|j�tt||!d��}"||d.d�}#i}$d/D]c}%d0|%}&|||&t�}'t|'t��rJt|'|!|&�}'t|'�}'|'|$|&<d1|%}(t|||(d��})|)|$|(<d2|%}*t|||*d3��}+|+|$|*<d4|%},t|||,d��}-|-|$|,<|'tu�r�|+�s�|j�d5||&f��q2|�r�|$d6tdfv�r�|j�d7|�d|$d6<||d8d|!d9�}.|.du�r�td:|��||fid;t||!d(��d8|.�d.|#�d'|�d|	�d|
�d
|�d|�d
|
�d<|�d=|$d=�d |�d!|�d>|$d>�d?|$d?�d@|$d@�d6|$d6�d"|�d#|�dA|$dA�dB|$dB�dC|$dC�d|�d|�d|�d|�d|�d|�d|"�d$|��}/|�|/��q
|��|S)DNrjrp)rTrCr
rYcs8|�di�}|���||d<�j||g|�Ri|��Srr8)r�r�r�r�rrr2r3r��s
z2ServerOptions._processes_from_section.<locals>.getr:r;�	autostart�true�autorestart�
unexpected�	startsecs�startretries��
stopsignal�TERM�stopwaitsecsr��stopasgroupr�killasgroup�	exitcodes�0rB�numprocs�numprocs_startrrrqF)�	do_expand�stdout_capture_maxbytes�stdout_events_enabled�stderr_capture_maxbytes�stderr_events_enabledr�AUTOr�r��process_namez%(program_name)sz%(process_num)zD%(process_num) must be present within process_name when numprocs > 1z1Cannot set stopasgroup=true and killasgroup=false)�process_numr�r�)rarfz
%s_logfilez%s_logfile_backupsz%s_logfile_maxbytesrz	%s_syslogztFor [%s], AUTO logging used for %s without rollover, set maxbytes > 0 to avoid filling up filesystem unintentionally�stderr_logfilezpFor [%s], redirect_stderr=true but stderr_logfile has also been set to a filename, the filename has been ignored�commandrHz-program section %s does not specify a commandrxr��stdout_logfile�stdout_logfile_backups�stdout_logfile_maxbytes�
stdout_syslog�stderr_logfile_backups�stderr_logfile_maxbytes�
stderr_syslog)rJr
r�r!r"rTrrrrrrr.r>r
rrs�rangerrPrr&r�
isinstancerrr�rurU)0rSr�r�rYrur9rCr
r�r:rvrxrzr{r}rr�r�r�rBr�r��environment_str�stdout_cmaxbytes�
stdout_events�stderr_cmaxbytes�
stderr_eventsrr�r�r�r�r�rrr��logfilesrUr��lf_val�bu_key�backups�mb_key�maxbytes�sy_key�syslogr��pconfigr2rr3rsusD����
������
���������	�
���
�������������������!z%ServerOptions._processes_from_sectioncCsTg}|��D]!}|�|�r'|�dd�}t|�dkr|d}nd}|�||f�q|S)Nrjrp)r�r�r��lenru)rSr��styper�r�r�rxr2r2r3�_parse_servernamess

�z ServerOptions._parse_servernamescCsT|j}||dd�}||dd�}|dus|dur%|dus|dur%td|��||d�S)N�username�passwordz�Section [%s] contains incomplete authentication: If a username or a password is specified, both the username and password must be specified)r�r�)r�rs)rSr�r�r�r�r�r2r2r3�_parse_username_and_passwords��
z*ServerOptions._parse_username_and_passwordc
Cs�g}|�|d�}|D]B\}}i}|j}|�|�||��||d<tj|d<||dd�}|dur5td|��t|�\}	}|	|d<||d<||d<|�|�q
|�|d�}
|
D]�\}}i}|j}||d	dd
|j	id�}|durstd|��|�
�}||d<tj|d<t|�|d	<|�|�||��||d
d�}|dur�zt
|�}Wnty�td|��wd}||d
<||dd�}
|
dur�zt|
�}
Wnttfy�td|
��wd}
|
|d<||d<|�|�qU|S)N�inet_http_serverrxr�rzsection [%s] has no port valuerr��unix_http_serverr�rTrHzsection [%s] has no file value�chownzInvalid sockchown value %s)rrrr�chmodzInvalid chmod value %srk)r�r�rr�r�rrsrrurTr.r�r9rrrQ)rSr��configs�inet_serverdefsrxr�rZr�rr�unix_serverdefs�sfiler�r�r2r2r3r,+sb

��z(ServerOptions.server_configs_from_parsercCs |j��|��|j��dSr5)r$�before_daemonize�
_daemonize�after_daemonizer�r2r2r3�	daemonize`s
zServerOptions.daemonizec
Cst��}|dkr|j�d�t�d�|j�d�|jrKzt�|j�WntyA}z|j�	d|j|f�WYd}~nd}~ww|j�d|j�t�
d�td�|_t
_t
_t�
d�tdd�|_t
_t
_t�
d	�tdd�|_t
_t
_t��t�|j�dS)
Nrz"supervisord forked; parent exitingz#daemonizing the supervisord processzcan't chdir into %r: %szset current directory: %rz	/dev/nullrp�wre)r&�fork�logger�blather�_exitr�r��chdirr�criticalr r,�stdinrM�	__stdin__ra�
__stdout__rf�
__stderr__�setsidr�)rS�pid�errr2r2r3r�es2
����


zServerOptions._daemonizec	Cs�t��}zt|jd��}|�d|�Wd�n1swYWnttfy8|j�d|j�YdSwd|_	|j�
d|�dS)Nr�r�zcould not write pidfile %sTzsupervisord started with pid %s)r&�getpidr,r�rbrrr�r��unlink_pidfiler�)rSr�r1r2r2r3�
write_pidfile�s���zServerOptions.write_pidfilecCsV|jD]\}}|dtjkr|jr|d}|�|�q|jr$|�|j�|j��dS)Nr�r�)	�httpserversr�r��unlink_socketfiles�_try_unlinkr�r�r$r )rSrZ�server�
socketnamer2r2r3�cleanup�s
�zServerOptions.cleanupcC�&zt�|�WdStyYdSwr5)r&�unlinkrr�r2r2r3r���
�zServerOptions._try_unlinkcCsbg}|jD] \}}|��|����D]}t|dd�}||ur$|�|�qq|D]}|��q(dS)Nr�)r�r �get_socket_map�valuesr�ru)rS�dispatcher_serversrZr��
dispatcher�dispatcher_serverr2r2r3�close_httpservers�s
��
�zServerOptions.close_httpserverscCs|j��dSr5)r�r r�r2r2r3�close_logger��zServerOptions.close_loggercCs`|jj}t�tj|�t�tj|�t�tj|�t�tj|�t�tj|�t�tj|�dSr5)	r��receive�signal�SIGTERM�SIGINT�SIGQUIT�SIGHUP�SIGCHLD�SIGUSR2)rSr�r2r2r3�
setsignals�szServerOptions.setsignalscCs
|j��Sr5)r��
get_signalr�r2r2r3r��r�zServerOptions.get_signalc
Csz|�|�|_d|_WdStjye}zL|jdtjkr#|�d�n0d}tj	�
|jd�}|dur?|�d||jdf�n|�d|||jdf�WYd}~dSWYd}~dSWYd}~dSd}~wty}z|�|jd�WYd}~dSd}~ww)NTrz�Another program is already listening on a port that one of our HTTP servers is configured to use.  Shut this program down first before starting supervisord.z1Cannot open an HTTP server: socket.error reportedz%s %sz%s errno.%s (%d))�make_http_serversr�r�r�r�r��errno�
EADDRINUSErY�	errorcoder�rs)rSr�r/r@�	errornamer2r2r3�openhttpservers�s(�����zServerOptions.openhttpserverscCs$d|||f}|jd||jd�}|S)Nz%s-%s---%s-z.log)�suffix�prefix�dir)�
mktempfiler�)rSrxr��channelr�r�r2r2r3�get_autochildlog_name�s�z#ServerOptions.get_autochildlog_namec
Cs�|j}t�d|j�}zt�|�}Wnttfy$|j�	d�YdSw|D])}|�
|�rPtj�||�}z|�
|�Wq'ttfyO|j�	d|�Yq'wq'dS)Nz.+?---%s-\S+\.log\.{0,1}\d{0,4}zCould not clear childlog dirzFailed to clean up %r)r�ro�compiler�r&�listdirrrr�r�rpr'r+�remove)rSr��fnrer2r3�pathnamer2r2r3�clear_autochildlogdir�s$�
���z#ServerOptions.clear_autochildlogdircCstjSr5)�asyncore�
socket_mapr�r2r2r3r�	szServerOptions.get_socket_mapc	Cs:d}t||j�D]}zt�|�WqtyYqwdS)N�)r�r�r&r r)rS�startr?r2r2r3�cleanup_fdss��zServerOptions.cleanup_fdscCst�||�dSr5)r&�kill)rSr�r�r2r2r3r�r�zServerOptions.killc
Cs�zt�dtj�\}}W||fStyG}z-|jd}|tjtjfvr+|j�	d|�|tjkr6|j�
d�d\}}WYd}~||fSd}~ww)Nrrrz:waitpid error %r; a process may not be cleaned up properlyzEINTR during reap)NN)r&�waitpid�WNOHANGrr�r��ECHILD�EINTRr�r�r�)rSr��stsr��coder2r2r3r�s"
�
��
��zServerOptions.waitpidcs>�durdSzt��}Wn$ty0zt���}Wnty)d�YYSw|d}Ynwzt�|�}Wn
tyEd|YSwt��}||krPdS|dkrVdS|d}ttd	�r�|d��fd
d�t	�
�D�}|�d|�zt�|�Wn
t
y�YdSwzt�|�Wn
t
y�Yd
Swt�|�dS)z�Drop privileges to become the specified user, which may be a
        username or uid.  Called for supervisord startup and when spawning
        subprocesses.  Returns None on success or a string error message if
        privileges could not be dropped.NzNo user specified to setuid to!zCan't find username %rrezCan't find uid %rrz$Can't drop privilege as nonroot userr|�	setgroupscs g|]}�|dvr|d�qS)r|rer2)r��grprec�r�r2r3r�Vs
�z1ServerOptions.drop_privileges.<locals>.<listcomp>z&Could not set groups of effective userz(Could not set group id of effective user)r�rs�pwd�getpwnam�KeyError�getpwuidr&r�rv�grp�getgrall�insertrr�setgid�setuid)rSr�r��pwrec�current_uidr�rVr2rr3�drop_privileges0sL���
��zServerOptions.drop_privilegescCsb|jdurt��dkr|j�d�dSdS|�|j�}|dur*|j�d|j�dS|�|�dS)z�Set the uid of the supervisord process.  Called during supervisord
        startup only.  No return value.  Exits the process via usage() if
        privileges could not be dropped.Nrz�Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.zSet uid to user %s succeeded)r�r&r�r�rurr�rYrhr2r2r3�set_uid_or_exitis
�
�zServerOptions.set_uid_or_exitc	
Cs�g}ttd�r|�d|jtjdd��ttd�r$|�d|jtjdd��|D]U}|d}|d}|d}|d	}|}t�|�\}}||kr{|d
kr{||krS|d
krS|}zt�|||f�|j	�dt
��Wq&tjtfyz|�
|t
��Yq&wq&dS)
z�Set the rlimits of the supervisord process.  Called during
        supervisord startup only.  No return value.  Exits the process via
        usage() if any rlimits could not be set.�
RLIMIT_NOFILEa�The minimum number of file descriptors required to run this process is %(min_limit)s as per the "minfds" command-line argument or config file setting. The current environment will only allow you to open %(hard)s file descriptors.  Either raise the number of usable file descriptors in your environment (see README.rst) or lower the minfds setting in the config file to allow the process to start.)ri�min�resourcerx�RLIMIT_NPROCa�The minimum number of available processes required to run this program is %(min_limit)s as per the "minprocs" command-line argument or config file setting. The current environment will only allow you to open %(hard)s processes.  Either raise the number of usable processes in your environment (see README.rst) or lower the minprocs setting in the config file to allow the program to start.rrrirxrrz)Increased %(name)s limit to %(min_limit)sN)rvrrur�rr�r�	getrlimit�	setrlimitr��localsr�rsrY)	rS�limits�limit�	min_limit�resrirx�soft�hardr2r2r3�set_rlimits_or_exit|sJ
	��
	��
����z!ServerOptions.set_rlimits_or_exitcCs�d}t�|j�|_|jr|jst�|j|�tj|j|j||j	|j	|j
d�|jD]}|j�|�q+|j
D]}|j�|�q7|jD]}|j�|�qCdS)Nz&%(asctime)s %(levelname)s %(message)s
)�rotatingr�r�)r!r�r�r�r�r��
handle_stdout�handle_filer�r�r�r�r�r�r�r�r�)rS�formatrir2r2r3�make_logger�s&�


�zServerOptions.make_loggercCsddlm}|||�S)Nr)r�)�supervisor.httpr�)rSr�r�r2r2r3r��s
zServerOptions.make_http_serverscCr�r5)r&r r)rS�fdr2r2r3�close_fd�r�zServerOptions.close_fdcC�t��Sr5)r&r�r�r2r2r3r���zServerOptions.forkcCst�||�Sr5)r&�dup2)rS�frm�tor2r2r3r+�r�zServerOptions.dup2cCr)r5)r&�setpgrpr�r2r2r3r.�r*zServerOptions.setpgrpcCs
t�|�Sr5)r&�stat)rSr3r2r2r3r/�r�zServerOptions.statcCst�|t|��Sr5)r&rbr)rSr'�datar2r2r3rb�r�zServerOptions.writecCst�|||�Sr5)r&�execve)rSr3rNrr2r2r3r1�r�zServerOptions.execvecCs&dt_t�|||�\}}t�|�|Sr5)r&�
_urandomfdr��mkstempr )rSr�r�r�r'r3r2r2r3r��s
zServerOptions.mktempfilecC�t�|�dSr5)r&r�r�r2r2r3r��r�zServerOptions.removecCr4r5)r&r�)rSrr2r2r3r��r�zServerOptions._exitcCr4r5)r&r�)rS�maskr2r2r3�setumask�r�zServerOptions.setumaskcCs0gd�}dtjvrtjd}|r|�tj�}|S)z3Return a list corresponding to $PATH, or a default.)z/binz/usr/binz/usr/local/bin�PATH)r&rQr��pathsep)rSr'�pr2r2r3�get_path�s

zServerOptions.get_pathcCr)r5)r&r�r�r2r2r3�get_pidr*zServerOptions.get_pidcCsn|dur
td|��t�|tj�rtd|��t�|tj�d@s(td|��t�|tj�s5t	d|��dS)Nzcan't find command %rzcommand at %r is a directory�Izcommand at %r is not executablezno permission to run command %r)
�NotFoundr/�S_ISDIR�ST_MODE�
NotExecutable�S_IMODEr&�access�X_OK�NoPermission)rSr3rN�str2r2r3�check_execv_argss�zServerOptions.check_execv_argscCs0|j�d�|jjD]}t|d�r|��q
dS)Nzsupervisord logreopen�reopen)r�r��handlersrvrG)rSr|r2r2r3�
reopenlogss
��zServerOptions.reopenlogsc
CsZz	t�|d�}W|Sty,}z|jdtjtjtjfvr�d}WYd}~|Sd}~ww)Nir�)r&r-rr�r��EWOULDBLOCK�EBADFr)rSr'r0r/r2r2r3�readfds���zServerOptions.readfdcCstj�|jpi�dSr5)r&rQrrr�r2r2r3�process_environment#sz!ServerOptions.process_environmentcCr4r5)r&r�)rSr�r2r2r3r�&r�zServerOptions.chdirc
Cs�ddddddd�}zVt��\}}|||d<|d<t��\}}|||d<|d<|r9t��\}}|||d<|d<|d|d|dfD]}|dur\t�|tj�tjB}	t�|tj|	�qD|WStyw|��D]}|duru|�|�qj�w)	z� Create pipes for parent to child stdin/stdout/stderr
        communications.  Open fd in non-blocking mode so we can read them
        in the mainloop without blocking.  If stderr is False, don't
        create a pipe for stderr. N)�child_stdinr�ra�child_stdoutrf�child_stderrrOr�rarPrfrQ)	r&�pipe�fcntl�F_GETFL�O_NDELAY�F_SETFLrr�r()
rSrf�pipesr�rOrarPrQr'�flagsr2r2r3�
make_pipes)s8��
��zServerOptions.make_pipescC�*dD]}|�|�}|dur|�|�qdS)N)r�rarf�r�r(�rSrW�fdnamer'r2r2r3�close_parent_pipesH�

��z ServerOptions.close_parent_pipescCrZ)N)rOrPrQr[r\r2r2r3�close_child_pipesNr_zServerOptions.close_child_pipesr�r5)Lr;r<r=r��	sockchown�	sockchmodr�r�r��
passwdfiler�r�rr�r�r�r"�SupervisorStates�RUNNING�moodrVr�r�r[r�r�r�r)rRrIrsr�r�r,r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr r%r�r(r�r+r.r/rbr1r�r�r�r6r:r;rFrIrMrNr�rYr^r`r2r2r2r3r��s�0
<z*$
�
�54
		9<		
	
r�c@sHeZdZdZdZdZdZdZdZdZ	dd�Z
dd�Zdd�Zd	d
�Z
dS)�
ClientOptionsrpNcCs�tj|dd�t�|_t�|j_d|jj_d|jj_d|jj_d|jj_d|jj_	d|jj_
ddlm}d|if}|g|_
|jddd	dd
dd�|jdd
dd�|jddddtdd�|�dddd�|�dddd�|�dddd�dS) NF)rKr�r)�DefaultControllerPluginr}�interactivezsupervisorctl.interactive�irpr��promptzsupervisorctl.promptr�rzsupervisorctl.serverurlzs:z
serverurl=�http://localhost:9001r�zsupervisorctl.usernamer�z	username=r�zsupervisorctl.passwordzp:z	password=�historyzsupervisorctl.history_filezr:z
history_file=)r>rVr:r��
supervisorctlrirkrr�r��history_file�supervisor.supervisorctlrh�plugin_factoriesrLr)rSrh�default_factoryr2r2r3rV^s,








��zClientOptions.__init__cOs,tj|g|�Ri|��|jsd|_dSdS)Nrp)r>r�r�ri)rSrlrr2r2r3r�xs
�zClientOptions.realizec		Cs�|jj}d}t|d�s9tj�t|��|_|�|�st	d|��z
|�
|d�}d}Wnttfy8t	d|��wt
�}|j|_d|_z|�|�WntyX|�|�Ynw|r_|��|��}d|vrkt	d��|jd	d
d|jid�}|�d
�r�t|dd��}d|}||_|�d|j�|_|�d|j�|_|�d|j�|_|jd|jd|jid�}|r�t|�}||_||_nd|_d|_|j|�|dd�7_|S)NFr-rr%Trrnz0.ini file does not include supervisorctl sectionrrlrTrHrirjrrkr�r�rozsupervisor.ctl_factoryz
ctlplugin:)r�rnrvr&r'r)r9rTrXrsr,rrrrPr�	mysectionrrrr r�rr�rrkr�r�rorqr�)	rSr-r�r.r�r�rr'ror2r2r3r�}sd

���

�
�zClientOptions.read_configcCstjdt�|j|j|j�d�S)Nzhttp://127.0.0.1)�	transport)r�ServerProxyr#�SupervisorTransportr�r�rr�r2r2r3�getServerProxy�s��zClientOptions.getServerProxy)r;r<r=r�rirkrr�r�rorVr�r�rwr2r2r2r3rgTs9rgc@sPeZdZdZdd�Zddd�Zdd�Zed	ifd
d�Zeifdd
�Z	dd�Z
dS)rr�cOsNtsd|vr
d|d<d|vrd|d<tjj|g|�Ri|��i|_i|_dS)N�inline_comment_prefixes)�;�#�strictF)rr�RawConfigParserrVrtrr�r2r2r3rV�s
zUnhosedConfigParser.__init__�<string>cCs4z	tj�|||�WSty|�t|��YSw)z�Parse configuration data from a string.  This is intended
        to be used in tests only.  We add this method for Py 2/3 compat.)rr|�read_stringrrr)rS�string�sourcer2r2r3r~�s��zUnhosedConfigParser.read_stringcKspt|t�r|g}g}|D])}|j��}|�tjj||gfi|���t|j�t|�}|D]}||j	|<q-q|S)a%Attempt to read and parse a list of filenames, returning a list
        of filenames which were successfully parsed.  This is a method of
        RawConfigParser that is overridden to build self.section_to_file,
        which is a mapping of section names to the files they came from.
        )
r�r�	_sectionsr+rKrr|r-�	frozensetrt)rSr2r��ok_filenamesr3�
sections_orig�diffr�r2r2r3r-�s

��zUnhosedConfigParser.readTcCsxz|�||�}Wntjy|tur�|}Ynw|r:t|t�r:tt|j�	��t|�	���}t
||d||f�}|S)Nz%s.%s)r�r�
NoOptionError�_markerr�r�dict�listrrRr&)rSr��optionr}r�r�optval�combined_expansionsr2r2r3r��s��
�zUnhosedConfigParser.sanegetcKs|j|j|f||d�|��S)N)r}r)r�rs)rSr�r}rr�r2r2r3rs
��zUnhosedConfigParser.getdefaultcCs\d}|��D]%}|�|�D]\}}||vr*|dusJd��|�||�}|�|||�q
qdS)Nz%(here)szhere has not been set to a path)r�rRr_rM)rSrT�HERE_FORMATr�r�r�r2r2r3r$s���zUnhosedConfigParser.expand_hereN)r})r;r<r=rsrVr~r-r�r�rr$r2r2r2r3r�s
	
�rc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ConfigcCs|�|�Sr5)�__eq__�rS�otherr2r2r3�__ne__r�z
Config.__ne__cCs$|j|jkr|j|jkS|j|jkSr5�r:rxr�r2r2r3�__lt__�z
Config.__lt__cCs$|j|jkr|j|jkS|j|jkSr5r�r�r2r2r3�__le__r�z
Config.__le__cCs$|j|jkr|j|jkS|j|jkSr5r�r�r2r2r3�__gt__%r�z
Config.__gt__cCs$|j|jkr|j|jkS|j|jkSr5r�r�r2r2r3�__ge__+r�z
Config.__ge__cCsd|jt|�|jfS)Nz<%s instance at %s named %s>)�	__class__�idrxr�r2r2r3�__repr__1s�zConfig.__repr__N)	r;r<r=r�r�r�r�r�r�r2r2r2r3r�sr�c@sNeZdZgd�ZddgZdd�Zdd�Zdd	�Zd
d�Zdd
d�Z	dd�Z
dS)rJ)rxr�r�r�r�r:rvrxrzr{r�r�r�r�r�r�r�r�r�r�r�r�r}rr�r�r�rBrrcKsF||_|jD]
}t||||�q|jD]}t|||�|d��qdSr5)r��req_param_namesrw�optional_param_namesr�)rSr��paramsrxr2r2r3rVCs

�zProcessConfig.__init__cCsXt|t�sdS|j|jD]}tt||�t||�fvrq
t||�t||�kr)dSq
dS�NFT)r�rJr�r�rr�)rSr�rxr2r2r3r�Js
�zProcessConfig.__eq__cCs4|jdur|j�d�}|dur|�tj�S|j��S)z|Return a list corresponding to $PATH that is configured to be set
        in the process environment, or the system default.Nr7)rr�r�r&r8r�r:r�r2r2r3r:Vs


zProcessConfig.get_pathcCsN|jj}|jj}|j}|jtur|||d�|_|jtur%|||d�|_dSdS)Nrarf)r�r�r�rxr�rr�)rS�get_autoname�sidrxr2r2r3�create_autochildlogs_s

�z"ProcessConfig.create_autochildlogsNcCsddlm}||�}||_|S)Nr)�
Subprocess)�supervisor.processr�r6)rSr6r��processr2r2r3�make_processiszProcessConfig.make_processcCs�|j}|j�|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
|dur;|
j}||||�||<|durJ|
j	}||||�||<|durV|	|d|�||<||fS)Nrarfr�r��POutputDispatcher��PInputDispatcher�r@)
rBr�rY�supervisor.dispatchersr�r�r�r@�ProcessCommunicationStdoutEvent�ProcessCommunicationStderrEvent)rSr7�
use_stderrr9�	stdout_fd�	stderr_fd�stdin_fd�dispatchersr�r�r@�etyper2r2r3�make_dispatchersos zProcessConfig.make_dispatchersr5)r;r<r=r�r�rVr�r:r�r�r�r2r2r2r3rJ5s	

rJc@seZdZdd�ZdS)rOc
Cs�d}|j�|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
dd	lm}|dur<||d|�||<|durK|j}|
|||�||<|durW|	|d|�||<||fS)
NTrarfr�r)�PEventListenerDispatcherr�r�r�)	r�rYr�r�r�r�r�r@r�)
rSr7r�r9r�r�r�r�r�r�r�r@r�r2r2r3r��s$�z$EventListenerConfig.make_dispatchersN)r;r<r=r�r2r2r2r3rO�srOc@seZdZddd�Zdd�ZdS)rSNcCs.|durtd��ddlm}||�}||_|S)Nz FastCGI programs require a groupr)�FastCGISubprocess)�NotImplementedErrorr�r�r6)rSr6r�r�r2r2r3r��sz!FastCGIProcessConfig.make_processcCs4t�||�\}}|d}|dur||��||fS)Nr�)rJr�r )rSr7r�r9r�r2r2r3r��s
z%FastCGIProcessConfig.make_dispatchersr5)r;r<r=r�r�r2r2r2r3rS�s
rSc@�,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rLcCs||_||_||_||_dSr5)r�rxr:r*)rSr�rxr:r*r2r2r3rV�s
zProcessGroupConfig.__init__cCsBt|t�sdS|j|jkrdS|j|jkrdS|j|jkrdSdSr�)r�rLrxr:r*r�r2r2r3r��s
zProcessGroupConfig.__eq__cC�|jD]}|��qdSr5�r*r��rSrZr2r2r3�after_setuid��

�zProcessGroupConfig.after_setuidcC�ddlm}||�S)Nr)�ProcessGroup)r�r�)rSr�r2r2r3�
make_group��zProcessGroupConfig.make_groupN�r;r<r=rVr�r�r�r2r2r2r3rL�s

rLc@r�)
rPcCs.||_||_||_||_||_||_||_dSr5)r�rxr:r*r<rar=)rSr�rxr:r*r<rar=r2r2r3rV�s
z EventListenerPoolConfig.__init__cCs^t|t�sdS|j|jkr-|j|jkr-|j|jkr-|j|jkr-|j|jkr-|j|jkr-dSdSr�)r�rPrxr:r*r<rar=r�r2r2r3r��s
zEventListenerPoolConfig.__eq__cCr�r5r�r�r2r2r3r��r�z$EventListenerPoolConfig.after_setuidcCr�)Nr)�EventListenerPool)r�r�)rSr�r2r2r3r��r�z"EventListenerPoolConfig.make_groupNr�r2r2r2r3rP�s

rPc@�$eZdZdd�Zdd�Zdd�ZdS)rTcCst�|||||�||_dSr5)rLrVrg)rSr�rxr:r*rgr2r2r3rV�s�
zFastCGIGroupConfig.__init__cCs*t|t�sdS|j|jkrdSt�||�S)NF)r�rTrgrLr�r�r2r2r3r��s

zFastCGIGroupConfig.__eq__cCr�)Nr)�FastCGIProcessGroup)r�r�)rSr�r2r2r3r��r�zFastCGIGroupConfig.make_groupN)r;r<r=rVr�r�r2r2r2r3rT�s
	rTc		Cst|�}t|�}zwt|d��g}||kr:|rtd��|�dd�|��}t||�}|dkr/d}|�|�|�|�}n)||krBtd��|dkrP|�|�|��}n|�|�|�|�}Wd�W|SWd�W|SWd�W|S1sxwYW|Sttfy�td��w)zJ Read length bytes from the file named by filename starting at
    offset �rb�
BAD_ARGUMENTSrreN�FAILED)	�absr,rs�seek�tellr�r-rr)	r3�offset�length�	absoffset�	abslengthr1�sz�posr0r2r2r3�readFilesD



��������r�c	Cs�zit|d��Y}d}|�dd�|��}|||krd}|d}|||kr1||dkr-d}||}|dkr7d}|dkr=d}|dkrDd}n
|�|�|�|�}|}t|�||gWd�WS1sbwYWdSttfyyd	|dgYSw)
a
    Read length bytes from the file named by filename starting at
    offset, automatically increasing offset and setting overflow
    flag if log size has grown beyond (offset + length).  If length
    bytes are not available, as many bytes as are available are returned.
    r�FrreTrprJNrq)r,r�r�r-rrr)r3r�r�r1�overflowr�r0r2r2r3�tailFile"s4

(��r�cCs�t�|�rt�|�d@}d|}||fSt�|�r=t�|�}dt|�}ttd�r/t�|�}n|d@}|r9|d7}d|fSd|}d|fS)	a*Decode the status returned by wait() or waitpid().

    Return a tuple (exitstatus, message) where exitstatus is the exit
    status, or -1 if the process was killed by a signal; and message
    is a message telling what happened.  It is the caller's
    responsibility to display the message.
    rEzexit status %szterminated by %s�	WCOREDUMP�z (core dumped)rrz unknown termination cause 0x%04x)r&�	WIFEXITED�WEXITSTATUS�WIFSIGNALED�WTERMSIG�signamervr�)r�esri�sig�iscorer2r2r3�decode_wait_statusKs



r�cCs tdurt�t�|�pd|S)z�Return a symbolic name for a signal.

    Return "signal NNN" if there is no corresponding SIG name in the
    signal module.
    Nz	signal %d)�	_signames�_init_signamesr�)r�r2r2r3r�gsr�cCsNi}tj��D]\}}t|dd�}|durq|d�r"|d�s"|||<q|adS)Nr��SIG�SIG_)r��__dict__rRr�r�)�drUr8�k_startswithr2r2r3r�rs�r�c@r�)r�cCs
g|_dSr5)�_signals_recvdr�r2r2r3rV~r�zSignalReceiver.__init__cCs||jvr
|j�|�dSdSr5)r�ru)rSr��framer2r2r3r��s
�zSignalReceiver.receivecCs|jr|j�d�}|Sd}|S)Nr)r��pop)rSr�r2r2r3r��s
�zSignalReceiver.get_signalN)r;r<r=rVr�r�r2r2r2r3r�}sr�cCs�z||WSty*}zt|���}|��td||t|�d�|�f��d}~wty@}ztd||t|�f��d}~ww)NzYFormat string %r for %r contains names (%s) which cannot be expanded. Available names: %srWz.Format string %r for %r is badly formatted: %s)rr�r�rUrsrgr+r�)r�rrx�ex�	availabler2r2r3r&�s&
�������r&cCs ||kr|}|Sd||f}|S)Nz%s:%sr2)rYr�rxr2r2r3�
make_namespec�s
�r�cCsJ|�dd�}t|�dkr|\}}|r|dkrd}||fS||}}||fS)Nrjrpre�*)r�r�)�namespec�namesrYr�r2r2r3�split_namespec�s
�r�c@�eZdZdZdS)�ProcessExceptionz@ Specialized exceptions used when attempting to start a process N�r;r<r=r�r2r2r2r3r���r�c@r�)�
BadCommandz5 Indicates the command could not be parsed properly. Nr�r2r2r2r3r��r�r�c@r�)r@z� Indicates that the filespec cannot be executed because its path
    resolves to a file which is not executable, or which is a directory. Nr�r2r2r2r3r@�r�r@c@r�)r=zR Indicates that the filespec cannot be executed because it could not
    be found Nr�r2r2r2r3r=�r�r=c@r�)rDz� Indicates that the file cannot be executed because the supervisor
    process does not possess the appropriate UNIX filesystem permission
    to execute the file. Nr�r2r2r2r3rD�r�rD)[r�r�r&rMr�r�r�rorr
rr/r�r'r!r�rS�supervisor.compatrrrrrrr�supervisor.medusar	r��supervisor.datatypesr
rrr
rrrrrrrrrrrrrrrrrrr r�r!r"r#r$r4r�r9r:r>r�rgr�r|r�objectr�rJrOrSrLrPrTr�r�r�r�r�r�r�r&r�r�r�r�r�r@r=rDr2r2r2r3�<module>s�IPmR L!")