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: //lib/python3/dist-packages/supervisor/__pycache__/rpcinterface.cpython-312.pyc
�

A�c�����ddlZddlZddlZddlZddlZddlmZddlmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZmZmZddlm Z ddlm!Z!ddlm"Z"ddlm#Z#ddlm$Z$m%Z%m&Z&dZ'Gd�d�Z(d�Z)d�Z*d�Z+d�Z,d�Z-d �Z.y)!�N)�	as_string)�as_bytes)�unicode)�	Automatic�
signal_number)�readFile)�tailFile)�
BadCommand)�
NotExecutable)�NotFound)�NoPermission)�
make_namespec)�split_namespec)�VERSION)�notify)�RemoteCommunicationEvent)�NOT_DONE_YET)�
capped_int�Faults�RPCError)�SupervisorStates)�getSupervisorStateDescription)�
ProcessStates)�getProcessStateDescription)�RUNNING_STATES�STOPPED_STATES�SIGNALLABLE_STATESz3.0c��eZdZd�Zd�Zd�ZeZd�Zd�Zd�Z	d�Z
d�ZeZd	�Z
d
�Zd�Zd�Zd
�Zd�Zd*d�Zd�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd+d�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d �Z$e$Z%d!�Z&d"�Z'd#�Z(e(Z)d$�Z*d%�Z+e+Z,d&�Z-d'�Z.d(�Z/y)),�SupervisorNamespaceRPCInterfacec��||_y�N��supervisord)�selfr#s  �9/usr/lib/python3/dist-packages/supervisor/rpcinterface.py�__init__z(SupervisorNamespaceRPCInterface.__init__1s
��&���c��||_t|jjjt
�rK|jjjtjkrttj��yyr!)�update_text�
isinstancer#�options�mood�intr�RUNNINGrr�SHUTDOWN_STATE)r$�texts  r%�_updatez'SupervisorNamespaceRPCInterface._update4sc�����
��(�(�0�0�5�5�s�
;�
�
�
�
%�
%�
*�
*�-=�-E�-E�
E��6�0�0�1�1�F�<r'c�0�|jd�tS)zb Return the version of the RPC API used by supervisord

        @return string version id
        �
getAPIVersion)r1�API_VERSION�r$s r%r3z-SupervisorNamespaceRPCInterface.getAPIVersion<s��
	
���_�%��r'c�0�|jd�tS)zo Return the version of the supervisor package in use by supervisord

        @return string version id
        �getSupervisorVersion)r1rr5s r%r7z4SupervisorNamespaceRPCInterface.getSupervisorVersionFs��
	
���+�,��r'c�d�|jd�|jjjS)zh Return identifying string of supervisord

        @return string identifier identifying string
        �getIdentification)r1r#r+�
identifierr5s r%r9z1SupervisorNamespaceRPCInterface.getIdentificationNs)��
	
���(�)����'�'�2�2�2r'c��|jd�|jjj}t	|�}||d�}|S)z� Return current state of supervisord as a struct

        @return struct A struct with keys int statecode, string statename
        �getState)�	statecode�	statename)r1r#r+r,r)r$�stater>�datas    r%r<z(SupervisorNamespaceRPCInterface.getStateVsE��
	
���Z� �� � �(�(�-�-��1�%�8�	��!����r'c�l�|jd�|jjj�S)z@ Return the PID of supervisord

        @return int PID
        �getPID)r1r#r+�get_pidr5s r%rBz&SupervisorNamespaceRPCInterface.getPIDes+��
	
���X�����'�'�/�/�1�1r'c	��|jd�|jjj}|�tj
j
|�sttj|��	tt|t|�t|���S#t$r-}|jd}ttt|���d}~wwxYw)z� Read length bytes from the main log starting at offset

        @param int offset         offset to start reading from.
        @param int length         number of bytes to read from the log.
        @return string result     Bytes of log
        �readLogNr)r1r#r+�logfile�os�path�existsrr�NO_FILErrr-�
ValueError�args�getattr)r$�offset�lengthrF�inst�whys      r%rEz'SupervisorNamespaceRPCInterface.readLogms���	
���Y���"�"�*�*�2�2���?�"�'�'�.�.��"9��6�>�>�7�3�3�	1��X�g�s�6�{�C��K�H�I�I���	1��)�)�A�,�C��7�6�3�/�0�0��	1�s�.'B�	C�(C�Cc��|jd�|jjj}|�%|jjj	|�sttj��	|jjj|�|jjjjD]N}t|d�s�|jjjjd�|j!��Py#ttf$rttj��wxYw)z^ Clear the main log.

        @return boolean result always returns True unless error
        �clearLog�reopenzreopening log fileT)r1r#r+rFrIrrrJ�remove�OSError�IOError�FAILED�logger�handlers�hasattr�inforT)r$rF�handlers   r%rSz(SupervisorNamespaceRPCInterface.clearLog�s���
	
���Z� ��"�"�*�*�2�2���?�$�"2�"2�":�":�"A�"A�'�"J��6�>�>�*�*�	*����$�$�+�+�G�4��'�'�/�/�6�6�?�?�	!�G��w��)�� � �(�(�/�/�4�4�5I�J���� �	!�����!�	*��6�=�=�)�)�	*�s�3%D�)D=c�x�|jd�tj|jj_y)zk Shut down the supervisor process

        @return boolean result always returns True unless error
        �shutdownT)r1r�SHUTDOWNr#r+r,r5s r%r_z(SupervisorNamespaceRPCInterface.shutdown�s-��
	
���Z� �(8�(A�(A���� � �%�r'c�x�|jd�tj|jj_y)zi Restart the supervisor process

        @return boolean result  always return True unless error
        �restartT)r1r�
RESTARTINGr#r+r,r5s r%rbz'SupervisorNamespaceRPCInterface.restart�s-��
	
���Y��(8�(C�(C���� � �%�r'c���|jd�	|jjjd��|jj�\}}}|D�cgc]}|j��}}|D�cgc]}|j��}}|D�cgc]}|j��}}|||ggS#t$r}ttj|��d}~wwxYwcc}wcc}wcc}w)a�
        Reload the configuration.

        The result contains three arrays containing names of process
        groups:

        * `added` gives the process groups that have been added
        * `changed` gives the process groups whose contents have
          changed
        * `removed` gives the process groups that are no longer
          in the configuration

        @return array result  [[added, changed, removed]]

        �reloadConfigF)�do_usageN)
r1r#r+�process_configrKrr�CANT_REREAD�diff_to_active�name)r$�msg�added�changed�removed�groups      r%rez,SupervisorNamespaceRPCInterface.reloadConfig�s��� 	
���^�$�	4����$�$�3�3�U�3�C�#'�"2�"2�"A�"A�"C���w��).�/�����/��/�+2�3�%�5�:�:�3��3�+2�3�%�5�:�:�3��3����)�*�*���	4��6�-�-�s�3�3��	4��
0��3��3s)�&B(�C�4C�
C�(	C�1C�Cc�2�|jd�|jjjD]J}|j|k(s�|jj|�}|st
tj|��yt
tj|��)z� Update the config for a running process from config file.

        @param string name         name of process group to add
        @return boolean result     true if successful
        �addProcessGroupT)
r1r#r+�process_group_configsrj�add_process_grouprr�
ALREADY_ADDED�BAD_NAME)r$rj�config�results    r%rqz/SupervisorNamespaceRPCInterface.addProcessGroup�s���	
���&�'��&�&�.�.�D�D�	�F��{�{�d�"��)�)�;�;�F�C���"�6�#7�#7��>�>��	��v����-�-r'c��|jd�||jjvrttj
|��|jj
|�}|sttj|��y)z� Remove a stopped process from the active configuration.

        @param string name         name of process group to remove
        @return boolean result     Indicates whether the removal was successful
        �removeProcessGroupT)r1r#�process_groupsrrru�remove_process_group�
STILL_RUNNING)r$rjrws   r%ryz2SupervisorNamespaceRPCInterface.removeProcessGroup�se��	
���)�*��t�'�'�6�6�6��6�?�?�D�1�1��!�!�6�6�t�<����6�/�/��6�6�r'c��g}|r�t|jjj��}|j	�|D]w}|jj|}t|j
j��}|j	�|D]$}|j
|}|j
||f��&�y|St|jjj��}	|	j	�|	D]O}t|j
j��}
|
j	�|
D]}|j
||f���Q|Sr!)�listr#rz�keys�sort�	processes�append�values)r$�lexical�
all_processes�group_names�
group_namero�
process_names�process_name�process�groupsr�s           r%�_getAllProcessesz0SupervisorNamespaceRPCInterface._getAllProcesses�s;���
���t�/�/�>�>�C�C�E�F�K�����)�
;�
��(�(�7�7�
�C�� $�U�_�_�%9�%9�%;� <�
��"�"�$�$1�;�L�#�o�o�l�;�G�!�(�(�%��)9�:�;�	
;�"���$�*�*�9�9�@�@�B�C�F��K�K�M��
;�� ����!7�!7�!9�:�	���� �(�;�G�!�(�(�%��)9�:�;�
;��r'c�"�t|�\}}|jjj|�}|�t	t
j|��|�|dfS|jj|�}|�t	t
j|��||fSr!)rr#rz�getrrrur�)r$rjr�r�ror�s      r%�_getGroupAndProcessz3SupervisorNamespaceRPCInterface._getGroupAndProcesss���#1�$�#7� �
�L�� � �/�/�3�3�J�?���=��6�?�?�D�1�1����$�;���/�/�%�%�l�3���?��6�?�?�D�1�1��g�~�r'c���
�|jd�|j��\}�
�
� t��\}}|j||�S	�
j	�\}}�
j�tvrt
tj ����
j�t"j$k(rt
tj&d�z���
j)�|j*j-��
j.rt
tj0����
j3�|r7�
j�t"j4k7r��
fd�}	d|	_||	_|	Sy#t
$r,}t
tj|jd��d}~wtttf$r,}t
tj|jd��d}~wwxYw)z� Start a process

        @param string name Process name (or ``group:name``, or ``group:*``)
        @param boolean wait Wait for process to be fully started
        @return boolean result     Always true unless error

        �startProcessNrz!%s is in an unknown process statec����jrttj����j	�}|t
jt
jfvrttj���|t
jk(rytS�NT)
�spawnerrrr�SPAWN_ERROR�	get_stater�STARTINGr.�ABNORMAL_TERMINATIONr)r?rjr�s ��r%�onwaitz<SupervisorNamespaceRPCInterface.startProcess.<locals>.onwaitOsp����#�#�"�6�#5�#5�t�<�<��)�)�+����!7�!7��9N�9N� O�O�"�6�#>�#>��E�E��M�1�1�1��#�#r'皙�����?T)r1r�r�startProcessGroup�get_execv_argsrrrrJrLr
rr
�NOT_EXECUTABLEr�r�ALREADY_STARTEDr�UNKNOWNrX�spawnr#�reapr�r��
transitionr.�delay�rpcinterface)r$rj�waitror�r��filename�argvrQr�r�s `        @r%r�z,SupervisorNamespaceRPCInterface.startProcesss����	
���^�$��1�1�$�7���w��?�'5�d�';�$�J���)�)�*�d�;�;�	?�$�3�3�5�N�H�d�����.�0��6�1�1�4�8�8�����-�"7�"7�7��6�=�=�>��E�G�
G�	�
�
��	
����������6�-�-�t�4�4�
	�����G�%�%�'�=�+@�+@�@�
$� �F�L�"&�F���M���u�	8��6�>�>�3�8�8�A�;�7�7���M�<�8�	?��6�0�0�#�(�(�1�+�>�>��	?�s$�E&�&	G�/'F�G�-'G�Gc��|jd�|jjj|�}|�t	t
j|��t|jj��}|j�|D�cgc]}||f��}}t|t|j|��}d|_||_|Scc}w)z� Start all processes in the group named 'name'

        @param string name     The group name
        @param boolean wait    Wait for each process to be fully started
        @return array result   An array of process status info structs
        r��r�r�)r1r#rzr�rrrur~r�r�r��make_allfunc�isNotRunningr�r�r�)r$rjr�ror�r��startalls       r%r�z1SupervisorNamespaceRPCInterface.startProcessGroupcs���	
���(�)�� � �/�/�3�3�D�9���=��6�?�?�D�1�1�����/�/�1�2�	�����6?�A�7�u�g�&�A�	�A��	�<��9J�9J�%)�+����� $������B��
Cc��|jd�|j�}t|t|j|��}d|_||_|S)z� Start all processes listed in the configuration file

        @param boolean wait    Wait for each process to be fully started
        @return array result   An array of process status info structs
        �startAllProcessesr�r�)r1r�r�r�r�r�r�)r$r�r�r�s    r%r�z1SupervisorNamespaceRPCInterface.startAllProcesses|sN��	
���(�)��)�)�+�	��	�<��9J�9J�%)�+����� $����r'c����|jd�|j|�\}��� t|�\}}|j||�S�j	�t
vrt
tj|���j�}|�t
tj|��|jj�|r+�j	�tvr�fd�}d|_||_|Sy)a Stop a process named by name

        @param string name  The name of the process to stop (or 'group:name')
        @param boolean wait        Wait for the process to be fully stopped
        @return boolean result     Always return True unless error
        �stopProcessc�^���j��j�tvrtSyr�)�stop_reportr�rr�r�s�r%r�z;SupervisorNamespaceRPCInterface.stopProcess.<locals>.onwait�s+����#�#�%��$�$�&�n�<�'�'�r'rT)r1r�r�stopProcessGroupr�rrr�NOT_RUNNING�stoprXr#r�rr�r�)	r$rjr�ror�r�rkr�r�s	        @r%r�z+SupervisorNamespaceRPCInterface.stopProcess�s����	
���]�#��1�1�$�7���w��?�'5�d�';�$�J���(�(��T�:�:�����n�4��6�-�-�t�4�4��l�l�n���?��6�=�=�#�.�.�	
�������G�%�%�'�~�=�
��F�L�"&�F���M�r'c��|jd�|jjj|�}|�t	t
j|��t|jj��}|j�|D�cgc]}||f��}}t|t|j|��}d|_||_|Scc}w)z� Stop all processes in the process group named 'name'

        @param string name     The group name
        @param boolean wait    Wait for each process to be fully stopped
        @return array result   An array of process status info structs
        r�r�r�)r1r#rzr�rrrur~r�r�r�r��	isRunningr�r�r�)r$rjr�ror�r��killalls       r%r�z0SupervisorNamespaceRPCInterface.stopProcessGroup�s���	
���'�(�� � �/�/�3�3�D�9���=��6�?�?�D�1�1�����/�/�1�2�	�����6?�A�7�u�g�&�A�	�A��y�)�T�5E�5E�$(�*����
�#������Br�c��|jd�|j�}t|t|j|��}d|_||_|S)z� Stop all processes in the process list

        @param  boolean wait   Wait for each process to be fully stopped
        @return array result   An array of process status info structs
        �stopAllProcessesr�r�)r1r�r�r�r�r�r�)r$r�r�r�s    r%r�z0SupervisorNamespaceRPCInterface.stopAllProcesses�sN��	
���'�(��)�)�+�	��y�)�T�5E�5E�$(�*����
�#����r'c��|jd�|j|�\}}|�!t|�\}}|j||��S	t	|�}|j�tvrt
tj|��|j|�}|�t
tj|��y#t
$rt
tj|��wxYw)z� Send an arbitrary UNIX signal to the process named by name

        @param string name    Name of the process to signal (or 'group:name')
        @param string signal  Signal to send, as name ('HUP') or number ('1')
        @return boolean
        �
signalProcess��signalT)r1r�r�signalProcessGrouprrKrr�
BAD_SIGNALr�rr�r�rX)	r$rjr�ror�r�r��sigrks	         r%r�z-SupervisorNamespaceRPCInterface.signalProcess�s���	
���_�%��1�1�$�7���w��?�'5�d�';�$�J���*�*�:�f�*�E�E�	6���'�C�����&8�8��6�-�-�t�4�4��n�n�S�!���{��6�=�=�#�.�.����	6��6�,�,�f�5�5�	6�s�
B3�3$Cc��|jjj|�}|jd�|�t	t
j|��t|jj��}|j�|D�cgc]}||f��}}t|t|j|��}|�}|jd�|Scc}w)z� Send a signal to all processes in the group named 'name'

        @param string name    The group name
        @param string signal  Signal to send, as name ('HUP') or number ('1')
        @return array
        r�r�)r#rzr�r1rrrur~r�r�r�r��
isSignallabler�)r$rjr�ror�r��sendallrws        r%r�z2SupervisorNamespaceRPCInterface.signalProcessGroups���� � �/�/�3�3�D�9�����)�*��=��6�?�?�D�1�1�����/�/�1�2�	�����5>�?�'�e�W�%�?�	�?��y�-��9K�9K�&,�.��������)�*��
��@s�
Cc��|j�}t|t|j|��}|�}|j	d�|S)z� Send a signal to all processes in the process list

        @param string signal  Signal to send, as name ('HUP') or number ('1')
        @return array         An array of process status info structs
        r��signalAllProcesses)r�r�r�r�r1)r$r�r��	signalallrws     r%r�z2SupervisorNamespaceRPCInterface.signalAllProcesses!sD���)�)�+�	� ��M�4�;M�;M���	�������)�*��
r'c��|jd�g}|jjjD�]�}|j|jj
v}|jD�]�}id|j�d|j�d|j�d|j�d|j�d|j�d|j�d	|�d
|j�d|j�d|j�d
|j�d|j�d|j �d|j"�d|j$�d|j&�|j(|j*|j,t/|j0�|j2|j4|j6|j8|j:|j<|j>|j@d��}|jCd�|jE�D��|jCd�|jE�D��|jG|�������|jId���|S)z� Get info about all available process configurations. Each struct
        represents a single process (i.e. groups get flattened).

        @return array result  An array of process config info structs
        �getAllConfigInfo�	autostart�	directory�uid�command�	exitcodesro�
group_prio�inuse�killasgrouprj�process_prio�redirect_stderr�startretries�	startsecs�stdout_capture_maxbytes�stdout_events_enabled�stdout_logfile)�stdout_logfile_backups�stdout_logfile_maxbytes�
stdout_syslog�
stopsignal�stopwaitsecs�stderr_capture_maxbytes�stderr_events_enabled�stderr_logfile�stderr_logfile_backups�stderr_logfile_maxbytes�
stderr_syslog�	serverurlc3�<K�|]\}}|tus�|df���y�w)�autoN)r��.0�k�vs   r%�	<genexpr>zCSupervisorNamespaceRPCInterface.getAllConfigInfo.<locals>.<genexpr>Ys����M���A�a�9�n�!�V��M�s��	c3�0K�|]\}}|��	|df���y�w)N�none�r�s   r%r�zCSupervisorNamespaceRPCInterface.getAllConfigInfo.<locals>.<genexpr>Zs����H���A�a�i�!�V��H�s�
�	c��|dS)Nrjr�)�rs r%�<lambda>zBSupervisorNamespaceRPCInterface.getAllConfigInfo.<locals>.<lambda>]s
��a��i�r')�key)%r1r#r+rrrjrz�process_configsr�r�r�r�r��priorityr�r�r�r�r�r�r�r�r�r�r-r�r�r�r�r�r�r�r�r��update�itemsr�r�)r$�
configinfo�gconfigr��pconfig�ds      r%r�z0SupervisorNamespaceRPCInterface.getAllConfigInfo.s[��	
���'�(��
��'�'�/�/�E�E�$	%�G��L�L�D�$4�$4�$C�$C�C�E�"�2�2�"
%���[�'�"3�"3�� �'�"3�"3���G�K�K�������!�'�"3�"3�	�
�g�l�l��"�7�#3�#3�
��e��#�G�$7�$7���W�\�\��$�W�%5�%5��'��(?�(?��$�W�%9�%9��!�'�"3�"3��/��0O�0O��-�g�.K�.K�� &�w�'=�'=�!�"07�/M�/M�07�0O�0O�&-�&;�&;�#&�w�'9�'9�#:�%,�%9�%9�07�0O�0O�.5�.K�.K�'.�'=�'=�/6�/M�/M�07�0O�0O�&-�&;�&;�")�"3�"3�9��>���M�����M�M����H�����H�H��!�!�!�$�E"
%�$	%�L	���/��0��r'c��|d}|tjk(r�|d}|d}tjtj|�dd�}tjtj|�dd�}||z
}t|�dkrtjd�}d|d�d|��}|S|tjtjfvr|d	}|sd
|dz}|S|tjtjfvrI|dr@|d}	tjtj|	�dd
�}
|
jd�}|Sd}|Sd}|S)Nr?�start�now�rzpid �pidz	, uptime r�zunknown error (try "tail %s")rjr��z%b %d %I:%M %pzNot started�)
rr.�datetime�time�gmtime�_total_seconds�	timedelta�FATAL�BACKOFF�STOPPED�EXITED�	localtime�strftime)r$r\r?r�r��start_dt�now_dt�uptime�descr��stop_dts           r%�_interpretProcessInfoz5SupervisorNamespaceRPCInterface._interpretProcessInfo`sb���W�
���M�)�)�)���M�E��u�+�C��(�(�$�+�+�e�*<�R�a�*@�A�H��&�&����C�(8��!�(<�=�F��h�&�F��f�%��)�!�+�+�A�.���*.�u�+�v�>�D�$��!�}�*�*�M�,A�,A�B�
B��
�#�D��6��f��E�����}�,�,�m�.B�.B�C�
C��G�}��F�|��"�+�+�T�^�^�D�-A�"�1�-E�F���'�'�(8�9����%��
���D��r'c��|jd�|j|�\}}|�ttj|��t|j�}t|j�}t|j��}|j�}|jxsd}|jxsd}	|jjxsd}
|jjxsd}|jj|jj||||t!|�||	|
|
||j"d�
}|j%|�}
|
|d<|S)z� Get info about a process named name

        @param string name The name of the process (or 'group:name')
        @return struct result     A structure containing data about the process
        �getProcessInforr)
rjror�r�r�r?r>r��
exitstatusrFr�r�r�description)r1r�rrrur�	laststart�laststop�_nowr�r�rrvr�r�rjrrr)r$rjror�r�r�r�r?r�rr�r�r\rs              r%rz.SupervisorNamespaceRPCInterface.getProcessInfos1��	
���%�&��1�1�$�7���w��?��6�?�?�D�1�1�
�7�,�,�-���'�*�*�+�������%���!�!�#���#�#�)�r���'�'�,�1�
� ���6�6�<�"�� ���6�6�<�"���>�>�&�&��L�L�%�%�����2�5�9��#�$�+�+��+�+��� �0�0��6��)��]���r'c�*�tj�Sr!)rr5s r%rz$SupervisorNamespaceRPCInterface._now�s���y�y�{�r'c��|jd�|jd��}g}|D]Y\}}t|jj|jj�}|j|j
|���[|S)zh Get info about all processes

        @return array result  An array of process status results
        �getAllProcessInfoT)r�)r1r�rrvrjr�r)r$r��outputror�rjs      r%rz1SupervisorNamespaceRPCInterface.getAllProcessInfo�sz��
	
���(�)��-�-�d�-�;�
���+�	5�N�E�7� ����!2�!2�G�N�N�4G�4G�H�D��M�M�$�-�-�d�3�4�	5��
r'c	���|j|�\}}|�ttj|��t	|j
d|z�}|�tjj|�sttj|��	tt|t|�t|���S#t$r-}|jd}	tt	t|	���d}~wwxYw)N�
%s_logfiler)r�rrrurMrvrGrHrIrJrrr-rKrL)
r$rjrNrO�channelror�rFrPrQs
          r%�_readProcessLogz/SupervisorNamespaceRPCInterface._readProcessLog�s����1�1�$�7���w��?��6�?�?�D�1�1��'�.�.�,��*@�A���?�"�'�'�.�.��"9��6�>�>�7�3�3�	1��X�g�s�6�{�C��K�H�I�I���	1��)�)�A�,�C��7�6�3�/�0�0��	1�s�'B.�.	C$�7(C�C$c�L�|jd�|j|||d�S)aI Read length bytes from name's stdout log starting at offset

        @param string name        the name of the process (or 'group:name')
        @param int offset         offset to start reading from.
        @param int length         number of bytes to read from the log.
        @return string result     Bytes of log
        �readProcessStdoutLog�stdout�r1r#�r$rjrNrOs    r%r%z4SupervisorNamespaceRPCInterface.readProcessStdoutLog��(��	
���+�,��#�#�D�&�&�(�C�Cr'c�L�|jd�|j|||d�S)aI Read length bytes from name's stderr log starting at offset

        @param string name        the name of the process (or 'group:name')
        @param int offset         offset to start reading from.
        @param int length         number of bytes to read from the log.
        @return string result     Bytes of log
        �readProcessStderrLog�stderrr'r(s    r%r+z4SupervisorNamespaceRPCInterface.readProcessStderrLog�r)r'c��|j|�\}}|�ttj|��t	|j
d|z�}|�tjj|�sgd�St|t|�t|��S)Nr!)rrF)r�rrrurMrvrGrHrIr	r-)r$rjrNrOr"ror�rFs        r%�_tailProcessLogz/SupervisorNamespaceRPCInterface._tailProcessLog�sr���1�1�$�7���w��?��6�?�?�D�1�1��'�.�.�,��*@�A���?�"�'�'�.�.��"9�!�!����V��c�&�k�:�:r'c�L�|jd�|j|||d�S)a�
        Provides a more efficient way to tail the (stdout) log than
        readProcessStdoutLog().  Use readProcessStdoutLog() to read
        chunks and tailProcessStdoutLog() to tail.

        Requests (length) bytes from the (name)'s log, starting at
        (offset).  If the total log size is greater than (offset +
        length), the overflow flag is set and the (offset) is
        automatically increased to position the buffer at the end of
        the log.  If less than (length) bytes are available, the
        maximum number of available bytes will be returned.  (offset)
        returned is always the last offset in the log +1.

        @param string name         the name of the process (or 'group:name')
        @param int offset          offset to start reading from
        @param int length          maximum number of bytes to return
        @return array result       [string bytes, int offset, bool overflow]
        �tailProcessStdoutLogr&�r1r.r(s    r%r0z4SupervisorNamespaceRPCInterface.tailProcessStdoutLog��(��&	
���+�,��#�#�D�&�&�(�C�Cr'c�L�|jd�|j|||d�S)a�
        Provides a more efficient way to tail the (stderr) log than
        readProcessStderrLog().  Use readProcessStderrLog() to read
        chunks and tailProcessStderrLog() to tail.

        Requests (length) bytes from the (name)'s log, starting at
        (offset).  If the total log size is greater than (offset +
        length), the overflow flag is set and the (offset) is
        automatically increased to position the buffer at the end of
        the log.  If less than (length) bytes are available, the
        maximum number of available bytes will be returned.  (offset)
        returned is always the last offset in the log +1.

        @param string name         the name of the process (or 'group:name')
        @param int offset          offset to start reading from
        @param int length          maximum number of bytes to return
        @return array result       [string bytes, int offset, bool overflow]
        �tailProcessStderrLogr,r1r(s    r%r4z4SupervisorNamespaceRPCInterface.tailProcessStderrLogr2r'c��|jd�|j|�\}}|�ttj|��	|j�y#ttf$rttj|��wxYw)z� Clear the stdout and stderr logs for the named process and
        reopen them.

        @param string name   The name of the process (or 'group:name')
        @return boolean result      Always True unless error
        �clearProcessLogsT)	r1r�rrru�
removelogsrWrVrX)r$rjror�s    r%r6z0SupervisorNamespaceRPCInterface.clearProcessLogs$sx��	
���'�(��1�1�$�7���w��?��6�?�?�D�1�1�	0���� �����!�	0��6�=�=�$�/�/�	0�s�A�*A>c�����|jd�g�g�|j�}|D]#\}}�j|||jf��%��fd�}d|_||_|S)zm Clear all process log files

        @return array result   An array of process status info structs
        �clearAllProcessLogsc�,���s�S�jd�\}}}t|jj|jj�}	||��j	|jj|jjt
jdd���rtS�S#t$r\}�j	|jj|jj|j|jd��Yd}~�jd}~wwxYw)Nr�OK�rjro�statusr)�poprrvrjr�r�SUCCESSr�coder0r)ror��callbackrj�e�	callbacks�resultss     ��r%�clearallzESupervisorNamespaceRPCInterface.clearAllProcessLogs.<locals>.clearallJs�������'0�}�}�Q�'7�$�E�7�H� ����!2�!2�G�N�N�4G�4G�H�D�
�������#�N�N�/�/�"�\�\�.�.�$�n�n�#'�)���#�#��N��#�
,����#�N�N�/�/�"�\�\�.�.��f�f�#$�6�6�+�,�,��
,�s�B.�.	D�7AD�Dr�)r1r�r��clearProcessLogr�r�)r$r�ror�rErCrDs     @@r%r9z3SupervisorNamespaceRPCInterface.clearAllProcessLogs<su���
	
���*�+����	��-�-�/�
�+�	E�N�E�7����e�W�d�.B�.B�C�D�	E�	�6��� $����r'c�&�|jd�t|tttf�sttj|��t|�}|j|�\}}|�ttj|��|jr|jrttj|��	|j|�y#t$r@}|j dt"j$k(rttj&|���d}~wwxYw)a� Send a string of chars to the stdin of the process name.
        If non-7-bit data is sent (unicode), it is encoded to utf-8
        before being sent to the process' stdin.  If chars is not a
        string or is not unicode, raise INCORRECT_PARAMETERS.  If the
        process is not running, raise NOT_RUNNING.  If the process'
        stdin cannot accept input (e.g. it was closed by the child
        process), raise NO_FILE.

        @param string name        The process name to send to (or 'group:name')
        @param string chars       The character data to send to the process
        @return boolean result    Always return True unless error
        �sendProcessStdinNrT)r1r*�str�bytesrrr�INCORRECT_PARAMETERSrr�rur�killingr��writerVrL�errno�EPIPErJ)r$rj�charsror�rQs      r%rHz0SupervisorNamespaceRPCInterface.sendProcessStdinis���	
���'�(��%�#�u�g�!6�7��6�6�6��>�>������1�1�$�7���w��?��6�?�?�D�1�1��{�{�g�o�o��6�-�-�t�4�4�	��M�M�%� ���
�	��x�x��{�e�k�k�)��v�~�~�t�4�4���		�s�5C�	D�;D�Dc��t|t�r|jd�}t|t�r|jd�}tt	||��y)aB Send an event that will be received by event listener
        subprocesses subscribing to the RemoteCommunicationEvent.

        @param  string  type  String for the "type" key in the event header
        @param  string  data  Data for the event body
        @return boolean       Always return True unless error
        zutf-8T)r*r�encoderr)r$�typer@s   r%�sendRemoteCommEventz3SupervisorNamespaceRPCInterface.sendRemoteCommEvent�sK���d�G�$��;�;�w�'�D��d�G�$��;�;�w�'�D��$�T�4�0�	
�r'N)F)T)0�__name__�
__module__�__qualname__r&r1r3�
getVersionr7r9r<rBrE�readMainLogrSr_rbrerqryr�r�r�r�r�r�r�r�r�r�r�r�rrrrr#r%�readProcessLogr+r.r0�tailProcessLogr4r6rFr9rHrTr�r'r%rr0s���'�2���J��3�
�2�1�(�K��.��+�:.� 
��6�"L�\�2� 1�f�2�"�>�2�0�d�>,�\�
�1�"	D�*�N�	D�;�D�,*�N�D�,�,'�O�+�Z$�Lr'rc�`�|jdz|jzdz|jzdzS)Ni�Qi@B)�days�seconds�microseconds)rs r%rr�s9��
�^�^�e�
#�i�&7�&7�
7�5�@��&�&�
'�*/�0�0r'c�"�g}g}||||||fd�}|S)zl Return a closure representing a function that calls a
    function for every process, and returns a result c	�|�|s�|D]�\}}t|jj|jj�}||�s�C	||fi|��}	t|	tj�r|j	|||	f��||j	|jj|jjtjdd����|s|S|ddD]v}|\}}}	|�}
|
tus�|j	|jj|jjtjdd��|j|��x|rtS|S#t$r]}
|j	|jj|jj|
j
|
jd��Yd}
~
���d}
~
wwxYw#t$rn}
|j	|jj|jj|
j
|
jd��|j|�Yd}
~
��^d}
~
wwxYw)Nr<r;)rrvrjrr�r@r0r*�types�FunctionTyperr?rrU)r��	predicate�func�extra_kwargsrCrDror�rjrArB�struct�cb�values              r%�allfunczmake_allfunc.<locals>.allfunc�s����"+�
���w�$�U�\�\�%6�%6����8K�8K�L���W�%�!�#'��#=��#=��"�(�E�,>�,>�?�!�(�(�%��(�)C�D����$+�N�N�$7�$7�%*�\�\�%6�%6�&,�n�n�+/�1��
�*��N���l�	-�F�!'��E�7�B�
-������,��N�N� '��� 3� 3�!&���!2�!2�"(�.�.�'+�-���$�$�V�,�+	-�.������[$�!����w�~�~�/B�/B�05���0A�0A�12���67�f�f�(>�?�!��!��2�
)����#�N�N�/�/�"�\�\�.�.��f�f�#$�6�6�+�,�
� � ��(�(��

)�s2�		E�"G�	G�$AF<�<G�	H;�
A#H6�6H;r�)r�rdrerfrCrDrjs       r%r�r��s/���I��G���
�!���
=�b�Nr'c�.�|j�tvSr!)r�rr�s r%r�r�s������.�0�0r'c��t|�Sr!)r�r�s r%r�r�s����!�!�!r'c�2�|j�tvryyr�)r�rr�s r%r�r�s������0�0��1r'c��t|�Sr!)rr"s r%�make_main_rpcinterfaceros
��*�;�7�7r')/rGrrrNrb�supervisor.compatrrr�supervisor.datatypesrr�supervisor.optionsrr	r
rrr
rrr�supervisor.eventsrr�supervisor.httpr�supervisor.xmlrpcrrr�supervisor.statesrrrrrrrr4rrr�r�r�r�ror�r'r%�<module>rws���	�����'�&�%��
(�'�)�,�'�+�,�-�&�$�6�(���/�;�+�8�����p
�p
�d0�X�t1�"��
8r'