HEX
Server: nginx/1.24.0
System: Linux prod-btpayments-io 6.14.0-1018-aws #18~24.04.1-Ubuntu SMP Mon Nov 24 19:46:27 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.3.19
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/supervisor/__pycache__/options.cpython-312.pyc
�

nC�cjY�� �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 lm4Z4dd!l5m6Z6dd"l5m7Z7dd#l5m8Z8dd$l5m9Z9d%�Z:e:�Z;d&�Z<Gd'�d(�Z=Gd)�d*�Z>Gd+�d,e>�Z?Gd-�d.e>�Z@gZAGd/�d0ej��ZCGd1�d2eD�ZEGd3�d4eE�ZFGd5�d6eF�ZGGd7�d8eF�ZHGd9�d:eE�ZIGd;�d<eE�ZJGd=�d>eI�ZKd?�ZLd@�ZMdA�ZNdaOdB�ZPdC�ZQGdD�dE�ZRdF�ZSdG�ZTdH�ZUGdI�dJeV�ZWGdK�dLeW�ZXGdM�dNeW�ZYGdO�dPeW�ZZGdQ�dReW�Z[y)S�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)�Syslog)�auto_restart)�profile_options)�loggers)�states)�xmlrpc)�pollerc�B�tjjtjjt��}tjj|d�}t
|d�5}|j�j�cddd�S#1swYyxYw)Nzversion.txt�r)	�os�path�abspath�dirname�__file__�join�open�read�strip)�mydir�version_txt�fs   �4/usr/lib/python3/dist-packages/supervisor/options.py�_read_version_txtr6:sf���G�G�O�O�B�G�G�O�O�H�5�6�E��'�'�,�,�u�m�4�K�	
�k�3�	� �1��v�v�x�~�~�� � � �s�-B�Bc��tjjtjjtjj	|���S�N)r)r*�normpathr+�
expanduser)�vs r5�normalize_pathr<As3��
�7�7���B�G�G�O�O�B�G�G�,>�,>�q�,A�B�C�C�c��eZdZy)�DummyN)�__name__�
__module__�__qualname__�r=r5r?r?Ds��r=r?c��eZdZejZej
ZejZeZdxZZ	ejdZdZdZ
dZdZdZdd�Zd�Zd�Zd�Z									dd�Zd�Zdd	�Zdd
�Zd�Zd�Zdd
�Zd�Zd�Zy)�OptionsNrc���g|_g|_g|_i|_i|_i|_i|_i|_||_|jdddd|j�|jdddd|j�|jdddd�tjjtjjtjd��}tjj!|d	d
�tjj!|d
�d
ddd
g}||_i|_tj&j)�D]\}}||j$d|z<�y)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.conf�ENV_%s)�
names_list�
short_options�long_options�options_map�default_map�required_map�environ_map�attr_priorities�require_configfile�addrHr)r*r,�sys�argvr.�searchpaths�environ_expansions�environ�items)�selfrU�hererY�kr;s      r5�__init__zOptions.__init__Ys6�����������������������!���"4�������t�S�&�$�)�)�4�����t�S�$��	�	�2�����t�T�+;�<��w�w���r�w�w���s�x�x��{�;�<���w�w�|�|�D�%�1C�D��w�w�|�|�D�*<�=�)�-�.�9���'���"$����J�J�$�$�&�	6�D�A�q�45�D�#�#�H�q�L�1�	6r=c���d}|jD]%}tjj|�s�#|}n|�9|jr-|jddj
|j�z�|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�, )rYr)r*�existsrU�usager.)r]�configr*s   r5�default_configfilezOptions.default_configfilezst�����$�$�	�D��w�w�~�~�d�#����	��>�d�5�5��J�J�-�/3�y�y��9I�9I�/J�K�
L��
r=c���|jdz}|jd�dkDr|jd|j�}|jj|�|j
d�y)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)r]�dummyrHs   r5rHzOptions.help�sR��
�x�x�$����9�9�T�?�Q���<�<��d�m�m�4�D������$���	�	�!�r=c���|jjdt|�z�|jjd|jz�|j	d�y)z2Print a brief error message to stderr and exit(2).z
Error: %s
zFor help, use %s -h
�N)�stderrrn�strrlro�r]�msgs  r5rdz
Options.usage�sD�������-�#�c�(�2�3������1�D�M�M�A�B��	�	�!�r=c
���|�]|�td��|s
|std��|r|jd�rtd��|r|jd�rtd��|fd�}|r6|r4|jd�|jd�k7rtd|�d|����|ry|d	d
k(rtd��|dd|dd}}
|d
vrtd��d
|
z}
|
|jvrtd|
z��||f|j|
<|jj	|�|ro|d	d
k(rtd��|}
|
ddk(r|
dd}
d|
z}
|
|jvrtd|
z��||f|j|
<|j
j	|�|	r||f|j|	<|rZt||�s
t||d�|jj	||f�|�||j|<|r||j|<yyy)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�:�=c��|Sr8rC)�arg�flags  r5�<lambda>zOptions.add.<locals>.<lambda>�s��T�r=z!inconsistent short/long options: � r�-z&short option should not start with '-'�)�rxz"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�endswithrPrN�appendrOrS�hasattr�setattrrMrQrR)r]�name�confname�short�long�handler�default�requiredr|�env�key�rests            r5rVzOptions.add�s4��@���"� �!H�I�I��� �!E�F�F������,� �!E�F�F���
�
�c�*� �!E�F�F�'+�1�G��T��~�~�c�"�d�m�m�C�&8�8� ��4�"!�"�"���Q�x�3�� �!I�J�J��b�q�	�5���9��C��9�$� �!E�F�F���)�C��d�&�&�&� �!B�S�!H�I�I�%)�7�O�D���S�!����%�%�e�,���A�w�#�~� �!H�I�I��C��2�w�#�~��#�2�h����*�C��d�&�&�&� �!A�C�!G�H�H�%)�7�O�D���S�!����$�$�T�*��%)�7�O�D���S�!���4��&���d�D�)��O�O�"�"�D�(�#3�4��"�)0�� � ��&��*2��!�!�$�'��
r=c��|jj|d�}||k\rt|||�||j|<yy)Nr�)rT�getr�)r]�attr�value�prio�currents     r5�_setzOptions._set�sB���&�&�*�*�4��4���7�?��D�$��&�)-�D� � ��&�r=c
�H�|�tjdd}|�tjd}|�	ddl}|j}||_||_g|_g|_	tj|dj|j�|j�\|_|_|jr3|j s'|jdt|j�z�|jD][\}}|j"|\}}	|	�		|	|�}|s�&|��)t'||��|jd	|z�|j)||d
��]|j*j-�D]^}|j*|\}}	|t.j0vs�(t.j0|}|	�		|	|�}|s�I|��L|j)||d��`|j2�|j5�|_|j7�y#t$rY���wxYw#tj$r%}|jt|��Yd}~���d}~wwxYw#t$$r%}
|jd|�d|�d|
���Yd}
~
��\d}
~
wwxYw#t$$r$}
|jd|�d|�d|
���Yd}
~
��d}
~
wwxYw)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__)
        Nr�rr�z*positional arguments are not supported: %szinvalid value for r~�: z"conflicting command line option %rrrzinvalid environment value for )rWrX�__main__�__doc__�	Exceptionrlri�options�args�getoptr.rNrO�errorrdrt�positional_args_allowedrPr��getattrr�rS�keysr)r[rJrf�process_config)
r]r�rirlr��exc�optr{r�r�rv�envvarr�s
             r5�realizezOptions.realize�sw���<��8�8�A�B�<�D����x�x��{�H��;�
���&�&��!��
���������	�	!�&,�m�m��b�g�g�d�0�0�1�4�3D�3D�'F�#�D�L�$�)��9�9�T�9�9��J�J�C�s�4�9�9�~�V�W����
	(�H�C�� �,�,�S�1�M�D�'��"�P�!�#�,�C�����4��&�2��J�J�C�c�I�J��	�	�$��Q�'�
	(��&�&�+�+�-�	.�F� �,�,�V�4�M�D�'�����#��
�
�6�*���&�;� '�����E�-��I�I�d�E�1�-�	.��?�?�"�"�5�5�7�D�O������c�
��
���|�|�	!��J�J�s�3�x� � ��	!��"�P��J�J��S�#�N�O�O��P��&�;��
�
�&,�e�S�$:�;�;��;�sZ�G8�AH�I�#I4�8	H�H�I�H;�;I�	I1�I,�,I1�4	J!�=J�J!c���|jr|j|�|jD]O\}}|s�	|jd�}|j}|D]}|�nt||�}�|j
||d��Q|jj�D]\}}t||���t|||��!|jj�D]#\}}t||���|j|��%y)z}Process configuration data structure.

        This includes reading config file if necessary, setting defaults etc.
        �.Nr)rJ�process_config_filerM�split�
configrootr�r�rQr\r�rRrd)	r]�do_usager�r��parts�obj�partr��messages	         r5r�zOptions.process_config8s���
�?�?��$�$�X�.�#�o�o�		(�N�D�(�� ���s�+���o�o��!�-�D��{��!�#�t�,�C�	-�
�	�	�$��Q�'�		(� �+�+�1�1�3�	+�K�D�%��t�T�"�*���d�E�*�	+�
"�.�.�4�4�6�	$�M�D�'��t�T�"�*��
�
�7�#�	$r=c�z�t|jd�sKtjj	tjj|j��|_	|j|j�y#t$r2}|r|jt|��nt|��Yd}~yd}~wwxYw)Nr0)r�rJr)r*r+r,r^�read_configr�rdrt)r]r�rvs   r5r�zOptions.process_config_fileWs����t����/��������������(H�I�D�I�	&����T�_�_�-���	&���
�
�3�s�8�$�!��o�%�%��	&�s�#A?�?	B:�(B5�5B:c�@�tjj|�Sr8)r)r*rc�r]r*s  r5rczOptions.existses���w�w�~�~�d�#�#r=c��t||�Sr8)r/)r]�fn�modes   r5r/zOptions.openhs���B��~�r=c��g}|j�D]�}|j|�s�|jdd�d}|j||d�}|�t	d|�d|����	|j|�}i}	|j|�D]}
|
|k7s�	|j||
�|	|
<�|j|||	f���|S#t$rt	|�d|�d���wxYw)Nrxr�z	section [z] does not specify a � cannot be resolved within [�])	�sections�
startswithr��sanegetr��import_spec�ImportErrorr�r�)r]�parser�factory_key�section_prefix�	factories�sectionr��factory_spec�factory�extrasr_s           r5�get_pluginszOptions.get_pluginsks	���	����(�	6�G��%�%�n�5���=�=��a�(��+�D�!�>�>�'�;��E�L��#� �")�;�"8�9�9�
,��*�*�<�8��
�F��^�^�G�,�
;����#� &���w�� :�F�1�I�
;�
���d�G�V�4�5�'	6�*����
,� � �'�"+�,�,�
,�s�$C�Cc��tjjd|z�}t|d�r|j	�S|jd�S)Nzx=�resolveF)�
pkg_resources�
EntryPoint�parser�r��load)r]�spec�eps   r5r�zOptions.import_spec�sB��
�
%�
%�
+�
+�D�4�K�
8���2�y�!��:�:�<���7�7�5�>�!r=�T)	NNNNNNNNN)NNN)r()r@rArBrWrsrmro�warnings�uid�gidrXrlrJ�	schemadirr�r^r�r`rfrHrdrVr�r�r�r�rcr/r�r�rCr=r5rErEGs���
�Z�Z�F�
�Z�Z�F��8�8�D��H���C�#��x�x��{�H��J��I��J��D� ��6�B�	�����������R3�h.�D�L$�>&�$���4"r=rEc��eZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZej j"Zd�Zd�Zd�Zd�Zd�Zd;d	�Zd
�Zd�Zd�Z	d<d
�Z	d<d�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d�Z.d �Z/d!�Z0d"�Z1d#�Z2d$�Z3d%�Z4d&�Z5d'�Z6d(�Z7d)�Z8d*�Z9d+�Z:d,�Z;d-�Z<d.�Z=d/�Z>d0�Z?d1�Z@d2�ZAd3�ZBd4�ZCd5�ZDd6�ZEd7�ZFd;d8�ZGd9�ZHd:�ZIy)=�
ServerOptionsNrCFc	���tj|�t�|_t�|j_|jdddd|j�|jdddddd��|jd	d
dd�|jd
dddtd��|jddddt�|jddddtd��|jddddtd ��|jd!d"d#d$td%��|jd&d'd(d)td*��|jd+d,d-d.td/��|jd0d1d2d3td4��|jd5d6d7d8ttj���|jd9d:d;d<t d=��|jd>d?d@dAt dB��|jdCdDdEdCdd��|jdFdGdHdFdd��|jdIdJd@dKt"d��|jdLdMdNdLdd��i|_g|_g|_g|_g|_t/�|_t3j4|�|_y)ONr;�version�nodaemonzsupervisord.nodaemon�nr�r�r|r��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.minprocsr�z	minprocs=���	nocleanupzsupervisord.nocleanupr_�
strip_ansizsupervisord.strip_ansi�tr"zsupervisord.profile_optionszprofile_options=�silentzsupervisord.silent�s)rEr`r?r��supervisordrVr�rrrrr
rrt�tempfile�
gettempdir�intr"�
pidhistory�process_group_configs�parse_criticals�parse_warnings�parse_infos�SignalReceiver�signal_receiverr&�Poller�r]s r5r`zServerOptions.__init__�s���������'���&+�g����#�����t�S�)�T�\�\�:�����3�S�*�1��	�	�����+�T�7�;�����-�t�X��U�	�	,�����5�t�\�#�	%�����1�4��!�+<�	�	>����#�%C��*�I�)�	�	+�	
���"�$A��)�7�B�	�	@�����3�T�;���	�	0�����1�4��!�+<�	�	>�����7��}��l�	�	,����� 9�4��#�X�-@�-@�-B�	�	D�����/��y�#�t�	�	5�����3��[�#�s�	�	4�����5��k��1�	�	6�����7��l��A�	�	7����"�$A��'��$�	�	H�����/��h�Q��	�	3����%'��"�!��� ������-�/����m�m�D�)��r=c�j�|jjdtz�|jd�y)z-Print version to stdout and exit(0).
        �%s
rN)rmrn�VERSIONro)r]rps  r5r�zServerOptions.version�s&��	
�����&�7�*�+��	�	�!�r=c�,�tj|i|��Sr8)r#�	getLogger�r]r��kwargss   r5rzServerOptions.getLogger�s��� � �$�1�&�1�1r=c��tj�dk(r|jjd�tj|�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��warnrErfrs r5rfz ServerOptions.default_configfile�s:��
�9�9�;�!���M�M����
��)�)�$�/�/r=c��tj|g|��i|��|jj}|j�-	t|j�}|_t|�|_
|js|j|_|jr
|j}n|j}|dk7rt|�|_|jr
|j}n|j}t|�|_|j|_d|_|j"x|_}|D�	cgc]}	|	dt$j&ur|	��c}	D]}	|	d}
d|
z|_n|j �F|D�	cgc]}	|	dt$j(ur|	��c}	D]}	|	d}|	d}|sd}d|�d	|��|_�yy#t$r}|j|�Yd}~��{d}~wwxYwcc}	wcc}	w)
N�syslog�family�file�	unix://%s�host�port�	localhostzhttp://rx)rEr�r�r�r�rr�rdr�rr�r�r�r<r��rpcinterface_factories�	serverurl�server_configs�socket�AF_UNIX�AF_INET)
r]r{�kwr�r�rvr�r��sconfigsrer*rrs
             r5r�zServerOptions.realize�s�������)�s�)�b�)��/�/�-�-���9�9� �
 �!�$�)�)�,���D�H�"�3�'�D�H��}�}�#�,�,�D�M��<�<��l�l�G��o�o�G��h��*�'�2�D�L��<�<��l�l�G��o�o�G�%�g�.���&-�&D�&D��#����)0�)?�)?�?���h�
.6�=�6��x�(�F�N�N�:��=�	�F��&�>�D�(�4�/�D�N��		��>�>�!�19�@�v�"�8�,����>�#�@�
?���f�~���f�~���&�D��37��!>���

?�"��U�
 ��
�
�3����
 ��F=��@s#�F-�$G�*G�-	G�6G
�
Gc��tj||��|jjj}||_y)N)r�)rEr�r�r�r)r]r��news   r5r�zServerOptions.process_config"s2�����t�h��7��o�o�)�)�?�?��%(��"r=c	�&���g|_g|_g|_|jj}d}t|d�s4|j
|�std|z��	|j|d�}d}t��|j�_
		�j|�|r|j)�	t+j,�}|j.|d�}|j1|j��j3d��r��j5|j.��j7dd	�std
���j9dd	�}t;||d�}|j=�}t|d�rGt>j@jCt>j@jE|jF��}nd
}|D]�}	t>j@jI||	�}	tKjJ|	�}
|
s|jjMd|	z��YtO|
�D]}}|jjMd|z�	�jQ|��j5t>j@jEt>j@jC|�������jS�}d|vrtd��d|j.i���fd�}
tU|
dd��|_+tU|
dd��|_,|
dd�}|�d|_-nt]|�|_-|
dd�|_/ta|
dd��|_1te|
dd��|_3ti|
dd��|_5tU|
d d!��|_6to|
d"d#��|_8te|
d$d%��|_9|
d&d'�|_:tw|
d(d)��|_<tw|
d*d)��|_=t}j~�}t]|
d+|��|_@tw|
d,d)��|_Atw|
d-d)��|_B|
d.d/�}t;||d.�}t�|�|_D|j�j��D]\}}||jd0|z<�|j��d1d2�|_G|j���|_I|j�D]O}|j�D]>}|j�j��}|j1|j��||_D�@�Q|j���|_Md|_N|S#ttf$rtd|z��wxYw#t$r�j!|�Y���wxYw#t"j$$r}tt'|���d}~wwxYw#|r|j)�wwxYw#t"j$$r}tt'|���d}~wwxYw)3NFr0�could not find config file %sr(T�could not read config file %s)r^�host_node_name�include�filesz5.ini file has [include] section, but no files settingz
include.filesr�r�z No file matches via include "%s"z'Included extra file "%s" during parsingr�z..ini file does not include supervisord sectionr^c�|��|jdi�}|j��||d<�j||fi|��S�N�
expansions)r��update�
getdefault)r�r�rr,�common_expansionsr�s    ��r5r�z&ServerOptions.read_config.<locals>.getosF������L�"�5�J����/�0�#-�F�<� �$�6�$�$�S�'�<�V�<�<r=r�r�r�r�r�r�r�r�r�r�r��50MBr�r�r�r�r�r�r�r�r��falser�r�r�r��environmentr�rLzsupervisor.rpcinterface_factoryz
rpcinterface:)Orrrr�r�r�rcr�r/�IOError�OSError�UnhosedConfigParserrZr,�	read_file�AttributeError�readfpr�ParsingErrorrt�close�platform�noder^r-�has_section�expand_here�
has_optionr��expandr�r)r*r,r+r�r.�globr��sortedr0r�r
r�r�r�rr�rr�rr�rr�r�rr�r�r�rr�r�r�r�r�r�r�rr2r\r�r�process_groups_from_parserr�process_configs�copy�server_configs_from_parserrr")r]�fpr��
need_close�whyr'r,r)�base�pattern�	filenames�filenamer�r�r��tempdir�environ_strr_r;�group�procr�r/r�s                      @@r5r�zServerOptions.read_config(s}��� "��� �������/�/�-�-���
��r�6�"��;�;�r�?� �!@�2�!E�F�F�
G��Y�Y�r�3�'��!�
�%�&�� �3�3���		�
"�� � ��$�����
�!�����!�Y�Y�'5�7�
����$�1�1�2����i�(����t�y�y�)��$�$�Y��8� �" �!�!��J�J�y�'�2�E��5�*�o�>�E��K�K�M�E��r�6�"��w�w���r�w�w���r�w�w�'?�@���� �
���'�'�,�,�t�W�5�� �I�I�g�.�	� ��'�'�.�.�:�W�D�F�� &�y� 1�
�H��$�$�+�+�A�H�L�N�����H�-��*�*��G�G�O�O�B�G�G�O�O�H�,E�F��
�
�&�?�?�$����(��M�N�N�#�D�I�I�.��	=�!��X�t�!4�5���"�3�z�3�#7�8�����T�*�	��� $�G�� 2�9� =�G���6�4�(���"�3�w��#6�7��
�*�3�y�:K�+L�M���#,�S�1C�V�-L�#M�� �")�#�.?��*D�"E���(��Z��)@�A���*�3�y�:K�+L�M��� ��|�<���"�3�z�7�#;�<��� ��X�w�!7�8����%�%�'��0��]�G�1L�M���#�C��W�$=�>���$�S��w�%?�@����-��,���[�*�m�D��5�k�B����'�'�-�-�/�	7�D�A�q�56�D�#�#�H�q�L�2�	7�
*.�)9�)9��-��*��&�
)-�(G�(G��(O��%��2�2�	'�E��-�-�
'���)�)�.�.�0���
�
�4�+�+�,�#&�� �
'�	'�
"&�!@�!@��!H���"&������]�W�%�
G� �!@�2�!E�F�F�
G��"�
"��
�
�b�!�
"���(�(�	'��S��X�&�&��	'������
���>(�4�4�3�(��S��2�2��3�s`�U�
U<�W$�U9�<V�V�V�V�W	�0W�W	�	W�W!�$X�7X�Xc��	��#�g}�j�}g}d|ji�#�#�fd�}|D]�}|jd�s�t|j	dd�d�}t||dd��}t
||dd��}	g}
|D]�}d	|z}d
|z}
||vr|
|vrtd|�d|����||vr|
|vrtd|�d
|�d���||vr|n|
}|j|�|j�||t�}|
j|���|jt|||	|
����|D]~}|jd�r||vr�t|j	dd�d�}t
||dd��}	|j�||t�}|jt|||	|����|D�]f}|jd�s�|j	dd�d}t
||dd��}	t
||dd��}|dkrtd||fz��||dd�}	|j|�}t||dd��D�cgc]}|j���}}t!|�}|std|z��ddlm}g}|D]4}t'||d�}|�td|�d|�d ���|j|��6t)||d!d"��}|rtd#|z��|j�||t*�}|jt-|||	||||����i|D�]/}|jd$�r||vr�t|j	dd�d�}t
||dd��}	d%|i}||d&d�}|�d}nt/|�}||d'd�}|�#t
|�}|dks|d(kDrtd)|z��||d*d�}|�	t1|�}||d,d�}|�	t3|�}||d.d|�/�} | std0|z��	|j7| ||||�}!|j�||t:�}|jt=|||	||!����2|j?�|S#t$rt|�d|�d���wxYwcc}w#t$rtd+|z��wxYw#t4tf$rtd-|z��wxYw#t$r}"tt9|"��d|�d1���d}"~"wwxYw)2Nr^c�~��|jdi�}|j��||d<�j|||fi|��Sr+�r�r-r�)r�r�r�rr,r/r�s     ��r5r�z5ServerOptions.process_groups_from_parser.<locals>.get�sF������L�"�5�J����/�0�#-�F�<� �!�6�>�>�'�3��B�6�B�Br=zgroup:rxr��programs�priority��z
program:%szfcgi-program:%s�[z(] names unknown program or fcgi-program z] name z2 is ambiguous (exists as program and fcgi-program)zprogram:zeventlistener:r��buffer_sizer�z*[%s] section sets invalid buffer_size (%d)�result_handlerz&supervisor.dispatchers:default_handlerr�r��eventsr�z&[%s] section requires an "events" liner)�
EventTypeszUnknown event type z in [z] events�redirect_stderrr1zx[%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�r,z%[%s] section requires a "socket" linez] socket) r�r^r�rr�rr
r�r��processes_from_section�
ProcessConfig�extend�ProcessGroupConfigr�r��upper�set�supervisor.eventsr\r�r�EventListenerConfig�EventListenerPoolConfigrrr�	TypeError�parse_fcgi_socketrt�FastCGIProcessConfig�FastCGIGroupConfig�sort)$r]r��groups�all_sections�homogeneous_excluder�r��
group_namerUrV�group_processes�program�program_section�fcgi_section�	processesr^�	pool_namerYrZ�x�pool_event_namesr\�pool_events�pool_event_name�
pool_eventr]�fcgi_expansions�	proc_user�proc_uidr_rarbr�
socket_config�er/s$ `                                 @r5rCz(ServerOptions.process_groups_from_parser�s=��������(�� ��#�D�I�I�.��	C�$�	�G��%�%�h�/��.�w�}�}�S�!�/D�Q�/G�H�J�&�s�7�J��'E�F�H��s�7�J��<�=�H� �O�#�
2��".��"8��0�7�:��&�,�6�|�|�?[�$�KR�T[�\�^�^�"�l�2�|�|�7S�%� �'�+�,�,�.=��-L�/�R^��#�*�*�7�3� �7�7���8B�M�S�	� �&�&�y�1�
2� 
�M�M�"�4��X��O�
�/	�8$�
	�G��(�(��4��2�2��0����s�A�1F�q�1I�J�L��s�7�J��<�=�H��1�1�&�'�<�2?�A�I��M�M�"�4��x��K�
�
	�$�3	�G��%�%�&6�7���
�
�c�1�-�a�0�I��s�7�J��;�<�H�!�#�g�}�b�"A�B�K��Q�� �!M��k�*�"+�,�,�!��*:�'O�Q�N�
.�!%�!1�!1�.�!A��!0��G�X�r�0J� K� M�a����	� M�� M�"�#3�4��#� �!I�!(�")�*�*�
5��K�#3�
/��$�Z��$�G�
��%�$�&5�w�&@�A�A��"�"�:�.�
/�&�c�'�3D�g�&N�O�O�� �"6�8?�"@�A�A��1�1�&�'�9�2E�G�I�
�M�M�'��i��9�(3�[�(6�8�
�_3	�l$�8	�G��(�(��9��2�2��0����s�A�1F�q�1I�J�L��s�7�J��<�=�H�-�|�<�O��G�V�T�2�I�� ���&�y�1�� ��*:�D�A�N��)�!(��!8��"�Q�&�.�5�*@�$�%F�>L�&M�N�N��w���=�L��'�P�#=�l�#K�L�
�g�}�d�;�K��&�O�",�[�"9�K�
��(�D�_�M�F�� �!H�!(�")�*�*�
J� $� 6� 6�v�x�4@�+�4B�!D�
��1�1�&�'�<�2F�H�I��M�M�"�4��x��#0�2�
�k8	�t	���
��
���
.� �"�G�"-�.�.�
.�� M��v"�P�$�%D�BN�&O�P�P�P��"�:�.�O�$�%C�BM�&N�O�O�O���
J� ��A���!H�I�I��
J�sB�#Q#�	R�R�R!�S�#Q>�R�!R?�	S*�S%�%S*c���|jd�rx|dd}tjj|�st	d|��t|�}|�(tj�}|�||k7r
|t|�f}|�d}t||||��S|�|�t	d��tjd|�}|r9|jd�}	t|jd	��}
t|	|
|�
�St	d|��)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+)$r�rr)r�zBad socket format %s)r�r)r*�isabsr�r<rrr�re�matchrPr�r)r]�sockr�rarbr_r*r��mrrs           r5rnzServerOptions.parse_fcgi_socketPs���?�?�9�%����8�D��7�7�=�=��&� �!N�!%�'�'�!�$�'�D��#��i�i�k���'�H��O�$,�k�(�.C�#D�L��"�#��)�$�l�5@�8F�H�
H��#�{�'>��@�A�
A�
�H�H�.��5����7�7�1�:�D��q�w�w�q�z�?�D�)�$��*�,�
,��/��6�6r=c	���	|j||||�S#t$r?}|jj||j�}t|�d|�d|�d���d}~wwxYw)Nz in section z (file: �))�_processes_from_sectionr��section_to_filer�rJ)r]r�r�ru�klassr�rMs       r5rdz$ServerOptions.processes_from_sectionssh��	7��/�/����U�4�
4���	7��-�-�1�1�'�4�?�?�K�H�� !�7�H�6�7�
7��	7�s��	A�:A�Ac�	��1�|�t}g}t|jdd�d�}tj�}|j
|||d��1�1�fd�}t
||dd��}	t||dd��}
t||d	d
��}t
||dd��}t
||dd
��}
t||dd��}t
||dd��}t||dd��}t||d|��}t||dd��}t||dd��}t
||dd��}t
||dd��}||ddd��}t||dd��}t||d d��}t||d!d��}t||d"d��}||d#d�}|r#|j�j�d$k(rd}||d%d�}|�d}nt|�}||d&d�}|�t|�}t||d'd(d���}|dkDrd)|vrt!d*��|r
|st!d+��t#|||z�D�]`} �1}!|!j%| |d,��|!j%|j&�t)t+||!d��}"|"j-�D]
\}#}$|$|!d-|#z<�||d.d�}%i}&d/D�]}#d0|#z}'|||'t.�}(t1|(t2�r
t+|(|!|'�}(t5|(�}(|(|&|'<d1|#z})t
|||)d��}*|*|&|)<d2|#z}+t|||+d3��},|,|&|+<d4|#z}-t|||-d��}.|.|&|-<|(t6ur1|j8j;d5|�d6|'�d7|-�d8��dx|&|'<}(d9|&|-<|(t.us��|,r��|j8j;d5|�d:|'�d;����|r0|&d<t.dfvr|j8j;d=|z�d|&d<<||d>d|!�?�}/|/�t!d@|z��||fidAt+||!d'��d>|/�d.|%�d&|�d|	�d|
�d	|�d|�d|
�dB|�dC|&dC�d|�d |�dD|&dD�dE|&dE�dF|&dF�d<|&d<�d!|�d"|�dG|&dG�dH|&dH�dI|&dI�d|�d|�d|�d|�d|�d|�d|"�d#|��}0|j;|0���c|j=�|S)JNrxr�)r^r^r'ruc���|jdi�}|j��||d<�j||g|��i|��Sr+rT)r�r�r�rr,r/r�s     ��r5r�z2ServerOptions._processes_from_section.<locals>.get�sI������L�"�5�J����/�0�#-�F�<� �!�6�>�>�'�3�@��@��@�@r=rVrW�	autostart�true�autorestart�
unexpected�	startsecs�startretries��
stopsignal�TERM�stopwaitsecsr��stopasgroupr1�killasgroup�	exitcodes�0r]�numprocs�numprocs_startrr2r�F)�	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�rLr�)rmrsz
%s_logfilez%s_logfile_backupsz%s_logfile_maxbytesr0z	%s_syslogzFor [z], z9=syslog but this is deprecated and will be removed.  Use z=true to enable syslog instead.Tz], AUTO logging used for zR 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�commandrcz-program section %s does not specify a commandr�r��stdout_logfile�stdout_logfile_backups�stdout_logfile_maxbytes�
stdout_syslog�stderr_logfile_backups�stderr_logfile_maxbytes�
stderr_syslog)rerr�r;r<r^r
rr!rrrr1rhrrr��ranger-rZrr@r\r�
isinstancer	rr rr�rq)2r]r�r�rur�rUr^r'r�rVr�r�r�r�r�r�r�r�r�r]r�r��environment_str�stdout_cmaxbytes�
stdout_events�stderr_cmaxbytes�
stderr_eventsrr�r�r�r�r�r,r2r_r;r��logfiles�lf_key�lf_val�bu_key�backups�mb_key�maxbytes�sy_keyrr��pconfigr/s2 `                                               @r5r�z%ServerOptions._processes_from_section}s[����=�!�E���,�W�]�]�3��-B�1�-E�F��!�����$(�I�I�%1�'5�#-�/��	A��3�w�
�C�8�9���C���f�=�>�	�"�3�w�
�|�#L�M���C���a�8�9�	��s�7�N�A�>�?��"�3�w��f�#E�F�
��s�7�N�B�?�@���c�'�=�'�B�C���c�'�=�+�F�G��%�c�'�;��&D�E�	�!�#�g�/@��"I�J���3�w�
�A�6�7�� ��W�.>��!B�C���g�}�b�E�J��$�S��1J�3�%O�P����G�-D�W� M�N�
�$�S��1J�3�%O�P����G�-D�W� M�N�
����d�3�	�����*�0�0�2�f�<��I��7�F�D�)���<��C��d�#�C��G�W�d�+�����u�%�E�,����);�u�M�O���a�<�#�|�3�!�#�$�$��{��C��
�!���N�1J�K�c	%�K�*�J����k�x�P�Q����d�5�5�6�1���
�M�B�D�K�$�)�)�+�
-���1�+,�
�8�a�<�(�
-��G�[�$�7�I��H�)�"
J��%��)���W�f�i�8���f�j�1�#�F�J��?�F�%�f�-��#)��� �-��1��!�#�g�v�r�":�;��#*��� �.��2��$�S��&�&�%A�B��#+��� �$�q��� ��W�f�e�!<�=��#)��� ��V�#��'�'�.�.� ���1�2�15�4�H�V�$�v�'+�H�V�$��Y�&�x��'�'�.�.�9@��I�J�?"
J�H��,�-�i��5F�F��'�'�.�.�"�$+�,�-�
.2��)�*��'�9�d�z�J�G��� �C�g�M�O�O���%��L�*�n�E�%� �%�$�	%�
�%�"�
%�$�%�(�%�$�%�*�%��%� (�(8�9�%�+;�%�)6�%�(0�0H�'I�%� )1�1J�(K�!%�"'��7�#%�$ (�(8�9�%%�&+;�'%�()6�)%�*(0�0H�'I�+%�,)1�1J�(K�-%�.'��7�/%�0&�1%�2*�3%�4(�5%�6(�7%�8$�9%�:!0�;%�<(�=%�>$�?%�G�B
�O�O�G�$�Gc	%�J	�
�
���r=c���g}|j�D]O}|j|�s�|jdd�}t|�dkDr|d}nd}|j	||f��Q|S)Nrxr�)r�r�r��lenr�)r]r��styper�r�r�r�s       r5�_parse_servernamesz ServerOptions._parse_servernames)sk�������(�	0�G��!�!�%�(��
�
�c�1�-���u�:��>� ��8�D��D�����g��/�	0��r=c�x�|j}||dd�}||dd�}|�|�|�|�td|z��||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�r�)r]r�r�r�r�r�s      r5�_parse_username_and_passwordz*ServerOptions._parse_username_and_password5sg���n�n���w�
�D�1���w�
�D�1����8�#7���8�#3� �>�@G�H�I�I�$��9�9r=c���g}|j|d�}|D]�\}}i}|j}|j|j||��||d<tj
|d<||dd�}|�t
d|z��t|�\}	}|	|d<||d<||d<|j|���|j|d�}
|
D]�\}}i}|j}||d	dd
|ji��}|�t
d|z��|j�}||d<tj|d<t|�|d	<|j|j||��||d
d�}|�
	t|�}nd}||d
<||dd�}
|
�
	t|
�}
nd}
|
|d<||d<|j|���|S#t$rt
d|z��wxYw#ttf$rt
d|
z��wxYw)N�inet_http_serverr�rrzsection [%s] has no port valuerr��unix_http_serverrr^rczsection [%s] has no file value�chownzInvalid sockchown value %s)r�r��chmodzInvalid chmod value %sr�)r�r�r-r�rrr�rr�r^r1rr<rrrm)r]r��configs�inet_serverdefsr�r�rer�rr�unix_serverdefs�sfiler�r�s              r5rFz(ServerOptions.server_configs_from_parserAsE�����1�1�&�:L�M��,�
	#�M�D�'��F��.�.�C��M�M�$�;�;�F�G�L�M�!�F�6�N�%�~�~�F�8���w���-�D��|� �!A�G�!K�L�L�%�d�+�J�D�$�!�F�6�N�!�F�6�N� '�F�9���N�N�6�"�
	#��1�1�&�:L�M��,�	#�M�D�'��F��.�.�C�����6�4�9�9�:M�N�E��}� �!A�G�!K�L�L��K�K�M�E�!�F�6�N�%�~�~�F�8��+�E�2�F�6�N��M�M�$�;�;�F�G�L�M����$�/�E�� �K�6�u�=�E�!��#�F�7�O����$�/�E�� �G�&�u�-�E���#�F�7�O� '�F�9���N�N�6�"�=	#�@���#"�K�$�%A�E�%I�J�J�K��"�:�.�G�$�%=��%E�F�F�G�s�"F/�G
�/G�
G(c��|jj�|j�|jj�yr8)r&�before_daemonize�
_daemonize�after_daemonizers r5�	daemonizezServerOptions.daemonizevs,�����$�$�&��������#�#�%r=c���tj�}|dk7r0|jjd�tjd�|jjd�|jrH	tj|j�|jjd|jz�tjd�td�x|_xt_t_tjd�tdd	�x|_xt_t_tjd
�tdd	�x|_xt_t_tj&�tj(|j(�y#t$r6}|jjd|j�d|���Yd}~��!d}~wwxYw)Nrz"supervisord forked; parent exitingz#daemonizing the supervisord processzset current directory: %rzcan't chdir into r�z	/dev/nullr��wrr)r)�fork�logger�blather�_exitr�r��chdirr4�criticalr:r/�stdinrW�	__stdin__rm�
__stdout__rs�
__stderr__�setsidr�)r]�pid�errs   r5r�zServerOptions._daemonize{sI��,�g�g�i���!�8��K�K��� D�E��H�H�Q�K������>�?��>�>�
3�������(�
��� � �!<�#'�>�>�"2�3�
�����15�k�1B�B��
�B�S�Y���
�����48��c�4J�J���J�c�j�3�>�
�����48��c�4J�J���J�c�j�3�>�
�	�	��
���������
>����$�$�(,����&=�>�>��
>�s�2F � 	G�)+G�Gc�p�tj�}	t|jd�5}|j	d|z�ddd�d|_|jjd|z�y#1swY�/xYw#ttf$r+|jjd|jz�YywxYw)Nr�r	Tzsupervisord started with pid %szcould not write pidfile %s)r)�getpidr/r�rn�unlink_pidfiler�r�r3r4r�)r]r�r4s   r5�
write_pidfilezServerOptions.write_pidfile�s����i�i�k��	F��d�l�l�C�(�
&�A�������%�
&�
#'�D���K�K���>��D�E�

&�
&����!�	N��K�K� � �!=����!L�M�	N�s(�A;�A/�A;�/A8�4A;�;7B5�4B5c�"�|jD]?\}}|dtjk(s�|js�*|d}|j	|��A|j
r|j	|j�|jj�y)Nrr)	�httpserversrr�unlink_socketfiles�_try_unlinkr�r�r&r:)r]re�server�
socketnames    r5�cleanupzServerOptions.cleanup�sy��"�.�.�	1�N�F�F��h��6�>�>�1��*�*�!'���J��$�$�Z�0�		1�
������T�\�\�*������r=c�N�	tj|�y#t$rYywxYwr8)r)�unlinkr4r�s  r5r�zServerOptions._try_unlink�s$��	��I�I�d�O���	��	����	$�$c�
�g}|jD][\}}|j�|j�j�D]%}t	|dd�}||us�|j|��'�]|D]}|j��y)Nr�)r�r:�get_socket_map�valuesr�r�)r]�dispatcher_serversrer��
dispatcher�dispatcher_servers      r5�close_httpserverszServerOptions.close_httpservers�s�����"�.�.�	:�N�F�F��L�L�N�"�1�1�3�:�:�<�
:�
�$+�J��$�$G�!�$��.�&�-�-�j�9�
:�	:�)�	�F�
�L�L�N�	r=c�8�|jj�yr8)r�r:rs r5�close_loggerzServerOptions.close_logger�s�������r=c���|jj}tjtj|�tjtj|�tjtj
|�tjtj|�tjtj|�tjtj|�yr8)	r�receive�signal�SIGTERM�SIGINT�SIGQUIT�SIGHUP�SIGCHLD�SIGUSR2)r]rs  r5�
setsignalszServerOptions.setsignals�s���&�&�.�.���
�
�f�n�n�g�.��
�
�f�m�m�W�-��
�
�f�n�n�g�.��
�
�f�m�m�W�-��
�
�f�n�n�g�.��
�
�f�n�n�g�.r=c�6�|jj�Sr8)r�
get_signalrs r5rzServerOptions.get_signal�s���#�#�.�.�0�0r=c�F�	|j|�|_d|_y#tj$r�}|j
dtjk(r|jd�n�d}tjj|j
d�}|�$|j|�d|j
d���n)|jd|||j
dfz�Yd}~yYd}~yYd}~yd}~wt$r(}|j|j
d�Yd}~yd}~wwxYw)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 reportedr~z%s errno.%s (%d))�make_http_serversr�r�rr�r��errno�
EADDRINUSErd�	errorcoder�r�)r]r�rIrH�	errornames     r5�openhttpserverszServerOptions.openhttpservers�s���	$�#�5�5�k�B�D��&*�D�#���|�|�
	?��x�x��{�e�.�.�.��
�
�E�F�
K��!�O�O�/�/������<�	��$��J�J�$������<�=��J�J�1� $�i����!��=� >�?�?�>�F���	$��J�J�s�x�x��{�#�#��	$�s!� �D �B*C,�,D �8D�D c�X�|�d|�d|�d�}|jd||j��}|S)Nrz---z.log)�suffix�prefix�dir)�
mktempfiler�)r]r�r��channelrr�s      r5�get_autochildlog_namez#ServerOptions.get_autochildlog_names7�� $�g�z�:���/�/���� � �"�"���r=c���|j}tjd|jz�}	t	j
|�}|D]F}|j|�s�tjj||�}	|j|��Hy#ttf$r|jjd�YywxYw#ttf$r!|jjd|z�Y��wxYw)Nz.+?---%s-\S+\.log\.{0,1}\d{0,4}zCould not clear childlog dirzFailed to clean up %r)r�r��compiler�r)�listdirr3r4r�rr�r*r.�remove)r]r��fnrerLrM�pathnames      r5�clear_autochildlogdirz#ServerOptions.clear_autochildlogdir
s����&�&���z�z�<�t���N�O��	��
�
�;�/�I�
"�	I�H��z�z�(�#��7�7�<�<��X�>��I��K�K��)�		I��	��!�	��K�K���;�<��	�� ��)�I��K�K�$�$�%<�x�%G�H�I�s#�B�=C�*B>�=B>�-C1�0C1c�"�tjSr8)�asyncore�
socket_maprs r5r�zServerOptions.get_socket_maps���"�"�"r=c�H�d}tj||j�y)N�)r)�
closeranger�)r]�starts  r5�cleanup_fdszServerOptions.cleanup_fds"s����
�
�
�e�T�[�[�)r=c�0�tj||�yr8)r)�kill)r]r�rs   r5r/zServerOptions.kill's��
����V�r=c��	tjdtj�\}}||fS#t$r�}|jd}|t
jt
jfvr|jjd|z�|t
jk(r|jjd�d\}}Yd}~||fSd}~wwxYw)Nr�rz:waitpid error %r; a process may not be cleaned up properlyzEINTR during reap)NN)r)�waitpid�WNOHANGr4r�r�ECHILD�EINTRr�r�r�)r]r��stsr��codes     r5r1zServerOptions.waitpid*s���	"��z�z�"�b�j�j�1�H�C���C�x����		"��8�8�A�;�D��E�L�L�%�+�+�6�6����$�$�?�AE�F���u�{�{�"����#�#�$7�8�!�H�C���C�x���		"�s�'-�	C�BC�Cc��|�y	t|�}	tj|�}t
j�}||k(ry|dk7ry|d}ttd	�rY|d}tj�D�cgc]}||dvs�|d��}}|jd|�	t
j|�	t
j|�t
j|�y#t$rd|zcYSwxYw#t$r6	tj
|�}n#t$r
d|zcYcYSwxYw|d}Y��wxYwcc}w#t$rYy
wxYw#t$rYywxYw)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 uid %rzCan't find username %rrrrz$Can't drop privilege as nonroot userr��	setgroupsz&Could not set groups of effective userz(Could not set group id of effective user)r��pwd�getpwuid�KeyErrorr��getpwnamr)rr��grp�getgrall�insertr8r4�setgid�setuid)r]r�r��pwrec�current_uidr��grprecrrs        r5�drop_privilegeszServerOptions.drop_privilegesBso��
�<�4�	1��d�)�C�
1����S�)���i�i�k���#��

��!��9��A�h���2�{�#���8�D�.1�l�l�n�!�F���Q�i�A �f�Q�i�!�F�!�
�M�M�!�S�!�
@����V�$�	>��I�I�c�N�	�	�	�#���G�
1�*�S�0�0�
1���	�
7����T�*����
7�/�$�6�6�
7����(�C�	��6!���
@�?�
@���	>�=�	>�sv�C4�C �6D6�D6�D;�5E
� C1�0C1�4	D3�>D�D3�D'�"D3�&D'�'D3�2D3�;	E�E�
	E�Ec�2�|j�4tj�dk(r|jj	d�yy|j|j�}|�)|jj	d|jz�y|j|�y)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)rrr�rErrdrus  r5�set_uid_or_exitzServerOptions.set_uid_or_exit{s����8�8���y�y�{�a���$�$�+�+�-1�2� ��&�&�t�x�x�0�C��{�� � �'�'�(F�(,���)1�2��
�
�3�r=c��g}ttd�r.|jd|jtjdd��ttd�r.|jd|j
tjdd��|D]�}|d}|d}|d}|d	}|}tj|�\}}||ks�7|d
k7s�=||kr|d
k7r|}	tj|||f�|jjdt�z���y#tjtf$r|j|t�z�Y��wxYw)
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.)rv�min�resourcer��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.rJrKrvr�r�z)Increased %(name)s limit to %(min_limit)sN)r�rKr�r�rIr�rL�	getrlimit�	setrlimitr�localsr�r�rd)	r]�limits�limit�	min_limit�resrvr��soft�hards	         r5�set_rlimits_or_exitz!ServerOptions.set_rlimits_or_exit�sP�����8�_�-��M�M�/��k�k�#�1�1�&�
�
��8�^�,��M�M�/��m�m�#�0�0�%�
�
� �	/�E��e��I��
�#�C���,�C���=�D��D�!�+�+�C�0�J�D�$��y� �t�r�z��9�$�4�2�:�%�D�/��&�&�s�Y��,=�>��$�$�+�+�-0�28�(�-;�<�#	/��&!���
�3�/��J�J�s�V�X�~�.�/�s�>D�5E�Ec�f�d}tj|j�|_|jr,|j
s tj|j|�tj|j|j||j|j|j��|jD]}|jj|��|jD]}|jj|��|jD]}|jj!|��y)Nz&%(asctime)s %(levelname)s %(message)s
)�rotatingr�r�)r#rr�r�r�r��
handle_stdout�handle_filer�r�r�rr�rrrr�)r]�formatrvs   r5�make_loggerzServerOptions.make_logger�s���:���'�'��
�
�6����=�=�����!�!�$�+�+�v�6�����K�K��L�L��!�2�2�2�2��*�*��(�(�
	
��'�'�	&�C��K�K� � ��%�	&��&�&�	"�C��K�K���S�!�	"��#�#�	"�C��K�K���S�!�	"r=c� �ddlm}|||�S)Nr)r)�supervisor.httpr)r]r�rs   r5rzServerOptions.make_http_servers�s��5� ��{�3�3r=c�N�	tj|�y#t$rYywxYwr8)r)r:r4)r]�fds  r5�close_fdzServerOptions.close_fd�s$��	��H�H�R�L���	��	�r�c�*�tj�Sr8)r)r�rs r5r�zServerOptions.fork�s���w�w�y�r=c�.�tj||�Sr8)r)�dup2)r]�frm�tos   r5rdzServerOptions.dup2�s���w�w�s�B��r=c�*�tj�Sr8)r)�setpgrprs r5rhzServerOptions.setpgrp�s���z�z�|�r=c�,�tj|�Sr8)r)�stat)r]rMs  r5rjzServerOptions.stat�s���w�w�x� � r=c�@�tj|t|��Sr8)r)rnr)r]r`�datas   r5rnzServerOptions.write�s���x�x��H�T�N�+�+r=c�0�tj|||�Sr8)r)�execve)r]rMrXr�s    r5rnzServerOptions.execve�s���y�y��4��-�-r=c�z�dt_tj|||�\}}tj|�|Sr8)r)�
_urandomfdr��mkstempr:)r]rrrr`rMs      r5rzServerOptions.mktempfile�s3����
��'�'����<���H�
������r=c�.�tj|�yr8)r)r"r�s  r5r"zServerOptions.removes
��
�	�	�$�r=c�.�tj|�yr8)r)r�)r]r6s  r5r�zServerOptions._exit�
��
����r=c�.�tj|�yr8)r)r�)r]�masks  r5�setumaskzServerOptions.setumask
rtr=c��gd�}dtjvr4tjd}|r|jtj�}|S)z3Return a list corresponding to $PATH, or a default.)z/binz/usr/binz/usr/local/bin�PATH)r)r[r��pathsep)r]r*�ps   r5�get_pathzServerOptions.get_path
s;��5���R�Z�Z���
�
�6�"�A���w�w�r�z�z�*���r=c�*�tj�Sr8)r)r�rs r5�get_pidzServerOptions.get_pids���y�y�{�r=c�^�|�td|z��tj|tj�rt	d|z��tj
|tj�dzst	d|z��t
j|tj�std|z��y)Nzcan't find command %rzcommand at %r is a directory�Izcommand at %r is not executablezno permission to run command %r)
�NotFoundrj�S_ISDIR�ST_MODE�
NotExecutable�S_IMODEr)�access�X_OK�NoPermission)r]rMrX�sts    r5�check_execv_argszServerOptions.check_execv_argss���
�:��2�X�=�>�>�
�\�\�"�T�\�\�*�
+�� >�� I�J�J��,�,�r�$�,�,�/�0�5�8�� A�H� L�M�M����8�R�W�W�-��@�8�K�L�L�.r=c��|jjd�|jjD]}t|d�s�|j	��!y)Nzsupervisord logreopen�reopen)r�r��handlersr�r�)r]r�s  r5�
reopenlogszServerOptions.reopenlogs&sB�������0�1��{�{�+�+�	!�G��w��)���� �	!r=c���	tj|d�}|S#t$rL}|jdtj
tjtjfvr�d}Yd}~|Sd}~wwxYw)Nirr=)r)r0r4r�r�EWOULDBLOCK�EBADFr4)r]r`rlrIs    r5�readfdzServerOptions.readfd,sb��	��7�7�2�w�'�D�
���	�	��x�x��{�5�#4�#4�e�k�k�5�;�;�"O�O���D����		�s��	A/�AA*�*A/c�.�tj|�yr8)r)r�)r]rs  r5r�zServerOptions.chdir5s
��
����
r=c�8�ddddddd�}	tj�\}}||c|d<|d<tj�\}}||c|d<|d<|r"tj�\}}||c|d<|d<|d|d|dfD]_}|��tj|tj�tjz}	tj|tj
|	��a|S#t$r+|j�D]}|��|j|���wxYw)	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�rm�child_stdoutrs�child_stderrr�r�rmr�rsr�)	r)�pipe�fcntl�F_GETFL�O_NDELAY�F_SETFLr4r�ra)
r]rs�pipesr�r�rmr�r�r`�flagss
          r5�
make_pipeszServerOptions.make_pipes8s-�� $��� $�� $�&��	�!#�����E�;�38�+�0�E�-� �%��.�#%�7�7�9� �F�L�5;�\�2�E�(�O�U�>�2��')�w�w�y�$���9?��6��h���~�!6��X���h���w��H�
:���>�!�K�K��E�M�M�:�R�[�[�H�E��K�K��E�M�M�5�9�
:��L���	��l�l�n�
&���>��M�M�"�%�
&�
�		�s�A;C%�AC%�%D�Dc�\�dD]'}|j|�}|��|j|��)y)N)r�rmrs�r�ra�r]r��fdnamer`s    r5�close_parent_pipesz ServerOptions.close_parent_pipesWs0��3�	"�F����6�"�B��~��
�
�b�!�	"r=c�\�dD]'}|j|�}|��|j|��)y)N)r�r�r�r�r�s    r5�close_child_pipeszServerOptions.close_child_pipes]s0��E�	"�F����6�"�B��~��
�
�b�!�	"r=r�r8)Jr@rArBr��	sockchown�	sockchmodr�r�r��
passwdfiler�r�r�r�r�r$�SupervisorStates�RUNNING�moodr`r�rrfr�r�r�rCrnrdr�r�r�rFr�r�r�r�r�rrrrrrr%r�r-r/r1rErGrVr\rrar�rdrhrjrnrnrr"r�rwr|r~r�r�r�r�r�r�r�rCr=r5r�r��s}���D��I��I��G��H��G��J��H�
�F��K��N����"�"�*�*�D�.*�`�2�
0�9?�|)�}�~g�R!7�H&*�7�'+�j�X
�
:�3�j&�
-�h	F����.�/�1�$�*�I�$#�*�
��07�r �&:/�x"�*4��� ��!�,�.�������M�!����>"�"r=r�c�@�eZdZdZdZdZdZdZdZdZ	d�Z
d�Zd�Zd�Z
y)�
ClientOptionsr�Nc���tj|d��t�|_t�|j_d|jj_d|jj_d|jj_d|jj_d|jj_	d|jj_
ddlm}d|if}|g|_
|jddd	dd
d��|jdd
d��|jddddtd��|jdddd�|jdddd�|jdddd�y) NF)rUr�r)�DefaultControllerPluginr��interactivezsupervisorctl.interactive�ir�r��promptzsupervisorctl.promptr�rzsupervisorctl.serverurlzs:z
serverurl=�http://localhost:9001r�zsupervisorctl.usernamer�z	username=r�zsupervisorctl.passwordzp:z	password=�historyzsupervisorctl.history_filezr:z
history_file=)rEr`r?r��
supervisorctlr�r�rr�r��history_file�supervisor.supervisorctlr��plugin_factoriesrVr)r]r��default_factorys   r5r`zClientOptions.__init__ms@������%��8��'���(-�����%�48����%�%�1�/;����%�%�,�26����%�%�/�15����%�%�.�15����%�%�.�59����%�%�2�D�$�&=�r�B��"1� 1������� ;�S��Q��	�	3�����1�<��H�����7��|��5�	�	7�����5�t�[�I�����5�t�[�I�����8�$��Pr=c�^�tj|g|��i|��|jsd|_yy)Nr�)rEr�r�r�)r]r{r s   r5r�zClientOptions.realize�s,������)�s�)�b�)��y�y� �D��r=c��|jj}d}t|d�satjjt
|��|_|j|�std|z��	|j|d�}d}t�}|j|_d|_	|j#|�|r|j)�|j+�}d|vrtd��|j-d	d
d|ji��}|j/d
�rt
|dd�}d|z}||_|j-d|j2�|_|j-d|j4�|_|j-d|j6�|_|j-d|j8d|ji��}|rt
|�}||_||_nd|_d|_|xj:|j=|dd�z
c_|S#ttf$rtd|z��wxYw#t$$r|j'|�Y���wxYw)NFr0r%r(Tr&r�z0.ini file does not include supervisorctl sectionrr�r^rcr�r�rr�r�r�r�zsupervisor.ctl_factoryz
ctlplugin:)r�r�r�r)r*r,r<r^rcr�r/r3r4r5rZr,�	mysectionr6r7r8r:r�r.r�rr�r�r�r�r�r�)	r]rGr�rHr�r�rr*r�s	         r5r�zClientOptions.read_config�sE���/�/�/�/���
��r�6�"�������r�(:�;�D�I��;�;�r�?� �!@�2�!E�F�F�
G��Y�Y�r�3�'��!�
�%�&�� �3�3���*���	����R� ���H�H�J��?�?�$���(�*��O�P�P��%�%�k�3J���	�	�*�&�,�	����	�*�!�)�A�B�-�0�D�#�d�*�I�%��� �*�*�8�W�^�^�D���!�,�,�Z��9I�9I�J���!�,�,�Z��9I�9I�J����(�(���9M�9M���	�	�*�)�,���)�,�7�L�#/�G� � ,�D��#'�G� � $�D������!1�!1��$��"�	�����Y�W�%�
G� �!@�2�!E�F�F�
G���	��M�M�"��	�s�2H�)H6�H3�6I�Ic��tjdtj|j|j
|j���S)Nzhttp://127.0.0.1)�	transport)r�ServerProxyr%�SupervisorTransportr�r�rrs r5�getServerProxyzClientOptions.getServerProxy�s=���$�$�
��2�2�4�=�=�37�=�=�37�>�>�C��	r=)r@rArBr�r�r�rr�r�r�r`r�r�r�rCr=r5r�r�cs<�����K�
�F��I��H��H��L�Q�4!�
6�r	r=r�c�D�eZdZdZd�Zd
d�Zd�Zedifd�Zeifd�Z	d�Z
y	)r5r�c��tsd|vrd|d<d|vrd|d<tjj|g|��i|��i|_i|_y)N�inline_comment_prefixes)�;�#�strictF)rr�RawConfigParserr`r�r,r
s   r5r`zUnhosedConfigParser.__init__�sY���(��6�4>��0�1��v�%�#(��x� ��$�$�-�-�d�D�T�D�V�D�!�����r=c��	tjj|||�S#t$r|j	t|��cYSwxYw)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_stringr7r8r)r]�string�sources   r5r�zUnhosedConfigParser.read_string�sJ��	1��/�/�;�;��f�f�&�
&���	1��;�;�x��/�0�0�	1�s� #�#A	�A	c�B�t|t�r|g}g}|D]�}|jj�}|j	tjj||gfi|���t|j�t|�z
}|D]}||j|<���|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	�	_sectionsrErfrr�r0�	frozensetr�)r]rLr�ok_filenamesrM�
sections_orig�diffr�s        r5r0zUnhosedConfigParser.read�s����i��,�"��I���!�	9�H� �N�N�/�/�1�M�����,�,�1�1�$��
�M�f�M�
O��T�^�^�,�y��/G�G�D��
9��08��$�$�W�-�
9�	9��r=Tc�H�	|j||�}|rht	|t
�rXt
t|jj��t|j��z�}t|||�d|���}|S#tj$r|tur�|}Y��wxYw)Nr�)r�r�
NoOptionError�_markerr�r	�dict�listr,r\r@)r]r��optionr�r�r,�optval�combined_expansionss        r5r�zUnhosedConfigParser.sanegets���	!��X�X�g�v�.�F���F�J�7�"&��T�_�_�*�*�,�-��Z�5E�5E�5G�0H�H�#J���F�$7�&-�v�6�8�F��
���)�)�	!��'�!�� ��		!�s�B�B!� B!c�D�|j|j|f||d�|��S)N)r�r,)r�r�)r]r�r�r,rs     r5r.zUnhosedConfigParser.getdefaults/���t�|�|�D�N�N�F�=�G�'1�=�5;�=�	=r=c���d}|j�D]N}|j|�D]8\}}||vs�|�Jd��|j||�}|j|||��:�Py)Nz%(here)szhere has not been set to a path)r�r\rkri)r]r^�HERE_FORMATr�r�r�s      r5r>zUnhosedConfigParser.expand_heresr�� ���}�}��	2�G�"�j�j��1�
2�
��U��%�'��+�N�-N�N�+�!�M�M�+�t�<�E��H�H�W�c�5�1�	
2�	2r=N)z<string>)r@rArBr�r`r�r0r�r�r.r>rCr=r5r5r5�s6���I�� 1��*07�$���&*1�R�=�2r=r5c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�Configc�&�|j|�Sr8)�__eq__�r]�others  r5�__ne__z
Config.__ne__%s���;�;�u�%�%�%r=c��|j|jk(r|j|jkS|j|jkSr8�rVr�r�s  r5�__lt__z
Config.__lt__(�8���=�=�E�N�N�*��9�9�u�z�z�)�)��}�}�u�~�~�-�-r=c��|j|jk(r|j|jkS|j|jkSr8r�r�s  r5�__le__z
Config.__le__.�8���=�=�E�N�N�*��9�9��
�
�*�*��}�}����.�.r=c��|j|jk(r|j|jkDS|j|jkDSr8r�r�s  r5�__gt__z
Config.__gt__4r�r=c��|j|jk(r|j|jk\S|j|jk\Sr8r�r�s  r5�__ge__z
Config.__ge__:r�r=c�T�d|j�dt|��d|j�d�S)N�<z
 instance at z named �>)�	__class__�idr�rs r5�__repr__zConfig.__repr__@s ��15����D��15���<�	<r=N)	r@rArBr�r�r�r�r�r�rCr=r5r�r�$s ��&�.�/�.�/�<r=r�c�B�eZdZgd�ZddgZd�Zd�Zd�Zd�Zdd	�Z	d
�Z
y)re)r�r�r�r�r�rVr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r]r2rc	��||_|jD]}t||||��|jD]}t|||j	|d���!yr8)r��req_param_namesr��optional_param_namesr�)r]r��paramsr�s    r5r`zProcessConfig.__init__RsZ������(�(�	.�D��D�$��t��-�	.��-�-�	8�D��D�$��
�
�4�� 6�7�	8r=c���t|t�sy|j|jzD]<}tt||�t||�fvr�"t||�t||�k7s�<yy�NFT)r�rer�r�rr�)r]r�r�s   r5r�zProcessConfig.__eq__Ysk���%��/���(�(�4�+D�+D�D�	�D��W�T�4�0�'�%��2F�G�G���t�T�"�g�e�T�&:�:��		�r=c���|j�<|jjd�}|�|jtj�S|j
j
�S)z|Return a list corresponding to $PATH that is configured to be set
        in the process environment, or the system default.ry)r2r�r�r)rzr�r|r�s  r5r|zProcessConfig.get_pathesR�����'��#�#�'�'��/�D����z�z�"�*�*�-�-��|�|�$�$�&�&r=c��|jj}|jj}|j}|jt
ur|||d�|_|jt
ur|||d�|_yy)Nrmrs)r�rr�r�r�rr�)r]�get_autoname�sidr�s    r5�create_autochildlogsz"ProcessConfig.create_autochildlogsnsl���|�|�9�9���l�l�%�%���y�y�����)�+�".�t�S�(�"C�D�����)�+�".�t�S�(�"C�D��,r=Nc�0�ddlm}||�}||_|S)Nr)�
Subprocess)�supervisor.processrrP)r]rPr�processs    r5�make_processzProcessConfig.make_processxs��1��T�"����
��r=c�*�|j}|jj|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
|�|
j}||||�||<|�|
j}||||�||<|�
|	|d|�||<||fS)Nrmrsr�r��POutputDispatcher��PInputDispatcher�r[)
r]r�r��supervisor.dispatchersr
rr�r[�ProcessCommunicationStdoutEvent�ProcessCommunicationStderrEvent)r]rQ�
use_stderrr{�	stdout_fd�	stderr_fd�stdin_fd�dispatchersr
rr[�etypes            r5�make_dispatcherszProcessConfig.make_dispatchers~s����-�-�-�
��L�L�#�#�J�/��'(��{�1�X�;�q��z�H�)�	���<�;�%�� ��:�:�E�%6�t�U�I�%N�K�	�"�� ��:�:�E�%6�t�E�9�%M�K�	�"���$4�T�7�H�$M�K��!��A�~�r=r8)r@rArBr�r�r`r�r|rrrrCr=r5rereDs5��
)�O�+�K�9��8�
�'�D��r=rec��eZdZd�Zy)rkc��d}|jj|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
dd	lm}|�
||d|�||<|�|j}|
|||�||<|�
|	|d|�||<||fS)
NTrmrsr�r)�PEventListenerDispatcherrr	r
)	r�r�rrrr
r�r[r)
r]rQrr{rrrrrrr
r[rs
             r5rz$EventListenerConfig.make_dispatchers�s����
��L�L�#�#�J�/��'(��{�1�X�;�q��z�H�)�	���C�;�<�%�� �%=�d�H�>G�&I�K�	�"�� ��:�:�E�%6�t�U�I�%N�K�	�"���$4�T�7�H�$M�K��!��A�~�r=N)r@rArBrrCr=r5rkrk�s��r=rkc��eZdZdd�Zd�Zy)roNc�J�|�td��ddlm}||�}||_|S)Nz FastCGI programs require a groupr)�FastCGISubprocess)�NotImplementedErrorrrrP)r]rPrrs    r5rz!FastCGIProcessConfig.make_process�s,���=�%�&H�I�I�8�#�D�)����
��r=c�p�tj||�\}}|d}|�||j�||fS)Nr�)rerr:)r]rQrr{rs     r5rz%FastCGIProcessConfig.make_dispatchers�sD��&�7�7��d�C���Q��W�:������!�'�'�)��A�~�r=r8)r@rArBrrrCr=r5roro�s���r=roc�$�eZdZd�Zd�Zd�Zd�Zy)rgc�<�||_||_||_||_yr8)r�r�rVrD)r]r�r�rVrDs     r5r`zProcessGroupConfig.__init__�s�������	� ��
�.��r=c���t|t�sy|j|jk7ry|j|jk7ry|j|jk7ryyr�)r�rgr�rVrDr�s  r5r�zProcessGroupConfig.__eq__�sP���%�!3�4���9�9��
�
�"���=�=�E�N�N�*�����5�#8�#8�8��r=c�F�|jD]}|j��yr8�rDr�r]res  r5�after_setuidzProcessGroupConfig.after_setuid��#���*�*�	*�F��'�'�)�	*r=c��ddlm}||�S)Nr)�ProcessGroup)rr))r]r)s  r5�
make_groupzProcessGroupConfig.make_group�s��3��D�!�!r=N�r@rArBr`r�r&r*rCr=r5rgrg�s��/��*�"r=rgc�$�eZdZd�Zd�Zd�Zd�Zy)rlc�f�||_||_||_||_||_||_||_yr8)r�r�rVrDrYr~rZ)r]r�r�rVrDrYr~rZs        r5r`z EventListenerPoolConfig.__init__�s7�������	� ��
�.���&���&���,��r=c�T�t|t�sy|j|jk(r~|j|jk(re|j|jk(rL|j
|j
k(r3|j|jk(r|j|jk(ryyr�)r�rlr�rVrDrYr~rZr�s  r5r�zEventListenerPoolConfig.__eq__�s����%�!8�9��
�Y�Y�%�*�*�
$�
�]�]�e�n�n�
,�
�
!�
!�U�%:�%:�
:�
�
�
��!2�!2�
2�
�
�
��!2�!2�
2�
�
 �
 �E�$8�$8�
8��r=c�F�|jD]}|j��yr8r$r%s  r5r&z$EventListenerPoolConfig.after_setuid�r'r=c��ddlm}||�S)Nr)�EventListenerPool)rr1)r]r1s  r5r*z"EventListenerPoolConfig.make_group�s��8� ��&�&r=Nr+rCr=r5rlrl�s��-��*�'r=rlc��eZdZd�Zd�Zd�Zy)rpc�D�tj|||||�||_yr8)rgr`r�)r]r�r�rVrDr�s      r5r`zFastCGIGroupConfig.__init__�s)���#�#������	�+��r=c��t|t�sy|j|jk7rytj	||�S)NF)r�rpr�rgr�r�s  r5r�zFastCGIGroupConfig.__eq__s:���%�!3�4������!4�!4�4��!�(�(��u�5�5r=c��ddlm}||�S)Nr)�FastCGIProcessGroup)rr6)r]r6s  r5r*zFastCGIGroupConfig.make_groups��:�"�4�(�(r=N)r@rArBr`r�r*rCr=r5rprp�s��+�6�)r=rpc�>�t|�}t|�}	t|d�5}||k7rg|rtd��|jdd�|j	�}t||z
�}|dkrd}|j|�|j
|�}nY||k7rtd��|dk(r"|j|�|j
�}n"|j|�|j
|�}ddd�|S#1swYSxYw#ttf$rtd��wxYw)zJ Read length bytes from the file named by filename starting at
    offset �rb�
BAD_ARGUMENTSrrrN�FAILED)	�absr/r��seek�tellr�r0r4r3)	rM�offset�length�	absoffset�	abslengthr4�sz�posrls	         r5�readFilerDs���F��I��F��I�#�
�(�D�
!�	*�Q��F�"��$�_�5�5����q�!���V�V�X���"�y�.�)����7��C����s���v�v�i�(����&�$�_�5�5��Q�;��F�F�6�N��6�6�8�D��F�F�6�N��6�6�&�>�D�)	*�0�K�1	*�0�K��
�W��#���"�"�#�s)�D�CC4�*D�4C>�9D�>D�Dc��	t|d�5}d}|jdd�|j�}|||zkDrd}|dz
}||z|kDr||dz
kDrd}||z
}|dkrd}|dkrd}|dk(rd}n"|j|�|j|�}|}t	|�||gcddd�S#1swYyxYw#t
tf$rd	|dgcYSwxYw)
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.
    r8FrrrTr�r=Nr�)r/r<r=r0rr4r3)rMr>r?r4�overflowrBrls       r5�tailFilerG1s���#�
�(�D�
!�	7�Q��H�
�F�F�1�a�L�����B��V�f�_�%����a������2�%��R�!�V�$��F��f�����z�����z�����{������v���v�v�f�~���F��d�O�V�X�6�5	7�	7�	7��6
�W��#��F�E�"�"�#�s/�B6�BB*� 	B6�*B3�/B6�3B6�6C
�C
c�\�tj|�r!tj|�dz}d|z}||fStj|�rYtj|�}dt|�z}t
td�rtj|�}n|dz}|r|dz
}d|fSd|z}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.
    r`zexit status %szterminated by %s�	WCOREDUMP�z (core dumped)r�z unknown termination cause 0x%04x)r)�	WIFEXITED�WEXITSTATUS�WIFSIGNALED�WTERMSIG�signamer�rI)r5�esrv�sig�iscores     r5�decode_wait_statusrSZs���
�|�|�C��
�^�^�C�
 �6�
)����#���3�w��	����	��k�k�#��� �7�3�<�/���2�{�#��\�\�#�&�F��4�Z�F���#�#�C��3�w��0�3�6���3�w�r=c�Z�t�
t�tj|�xsd|zS)z�Return a symbolic name for a signal.

    Return "signal NNN" if there is no corresponding SIG name in the
    signal module.
    z	signal %d)�	_signames�_init_signamesr�)rQs r5rOrOvs)�������=�=���2��s�!2�2r=c��i}tjj�D],\}}t|dd�}|��|d�s�|d�r�(|||<�.|ay)Nr��SIG�SIG_)r�__dict__r\r�rU)�dr_r;�k_startswiths    r5rVrV�s]��
�A����%�%�'����1��q�,��5��������|�F�';��A�a�D���Ir=c��eZdZd�Zd�Zd�Zy)rc��g|_yr8)�_signals_recvdrs r5r`zSignalReceiver.__init__�s
�� ��r=c�X�||jvr|jj|�yyr8)r_r�)r]rQ�frames   r5rzSignalReceiver.receive�s)���d�)�)�)����&�&�s�+�*r=c�\�|jr|jjd�}|Sd}|S)Nr)r_�pop)r]rQs  r5rzSignalReceiver.get_signal�s4������%�%�)�)�!�,�C��
��C��
r=N)r@rArBr`rrrCr=r5rr�s��!�,�r=rc
�2�	||zS#t$r]}t|j��}|j�t	d|�d|�dt|��ddj
|�����d}~wt$r"}t	d|�d|�dt|�����d}~wwxYw)NzFormat string z for z contains names (z-) which cannot be expanded. Available names: rbz is badly formatted: )r;r�r�rqr�rtr.r�)r�r,r��ex�	availables     r5r@r@�s���

��:�~����6�����*�+�	��������c�"�g�t�y�y��3�
5�6�	6���
��
��c�"�g�
�
�	
��
�s!��	B�AA(�(B�4B�Bc�&�||k(r|}|S|�d|��}|S)NrxrC)rur�r�s   r5�
make_namespecrh�s)���\�!����K�%�l�3���Kr=c�v�|jdd�}t|�dk(r|\}}|r|dk(rd}||fS||}}||fS)Nrxr�rr�*)r�r�)�namespec�namesrur�s    r5�split_namespecrm�sY���N�N�3��"�E�
�5�z�Q��#(� �
�L��|�s�2��L��|�#�#�$,�X�L�
��|�#�#r=c��eZdZdZy)�ProcessExceptionz@ Specialized exceptions used when attempting to start a process N�r@rArBr�rCr=r5roro�s��Jr=roc��eZdZdZy)�
BadCommandz5 Indicates the command could not be parsed properly. NrprCr=r5rrrr�s��?r=rrc��eZdZdZy)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. NrprCr=r5r�r��s��Mr=r�c��eZdZdZy)r�zR Indicates that the filespec cannot be executed because it could not
    be found NrprCr=r5r�r��s��r=r�c��eZdZdZy)r�z� Indicates that the file cannot be executed because the supervisor
    process does not possess the appropriate UNIX filesystem permission
    to execute the file. NrprCr=r5r�r��s��r=r�)\rr�r)rWr�rrr�r9r=rKrjr�rAr;r�r��supervisor.compatrrrrrrr	�supervisor.medusar
r'�supervisor.datatypesrrr
rrrrrrrrrrrrrrrrrrr r!r"r�r#r$r%r&r6r
r<r?rEr�r�r�r�r5�objectr�rerkrorgrlrprDrGrSrUrOrVrr@rhrmr�rorrr�r�r�rCr=r5�<module>rzs���
�
�	�
���
�	�
�
��������!�*�1�'�&�(�5�6�(�(�,�,�1�*�.�2�8�-�0�+�3�.�;�-�7�7�$�*�'�-�0����� �
�
��D�	�	�E"�E"�P
R"�G�R"�h&k�G�k�Z
��O2�,�6�6�O2�d<�V�<�@J�F�J�X�-��,�=��("��"�8'�f�'�B)�+�)�0 �D%#�R�4
�	�	3�	�
�
�"
� �
$�K�y�K�@�!�@�M�$�M�����#�r=