shell bypass 403

UnknownSec Shell


name : options.cpython-36.pyc
3

�k�`�Y�@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 lm4Z4dd!l5m6Z6dd"l5m7Z7dd#l5m8Z8dd$l5m9Z9d%d&�Z:e:�Z;d'd(�Z<Gd)d*�d*�Z=Gd+d,�d,�Z>Gd-d.�d.e>�Z?Gd/d0�d0e>�Z@gZAGd1d2�d2ejB�ZCGd3d4�d4eD�ZEGd5d6�d6eE�ZFGd7d8�d8eF�ZGGd9d:�d:eF�ZHGd;d<�d<eE�ZIGd=d>�d>eE�ZJGd?d@�d@eI�ZKdAdB�ZLdCdD�ZMdEdF�ZNdaOdGdH�ZPdIdJ�ZQGdKdL�dL�ZRdMdN�ZSdOdP�ZTdQdR�ZUGdSdT�dTeV�ZWGdUdV�dVeW�ZXGdWdX�dXeW�ZYGdYdZ�dZeW�ZZGd[d\�d\eW�Z[dS)]�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	CsDtjjtjjt��}tjj|d�}t|d��}|j�j�SQRXdS)Nzversion.txt�r)	�os�path�abspath�dirname�__file__�join�open�read�strip)ZmydirZversion_txt�f�r1�/usr/lib/python3.6/options.py�_read_version_txt:sr3cCstjjtjjtjj|���S)N)r'r(�normpathr)�
expanduser)�vr1r1r2�normalize_pathAsr7c@seZdZdS)�DummyN)�__name__�
__module__�__qualname__r1r1r1r2r8Dsr8c	@s�eZdZejZejZejZeZdZZ	ej
dZdZdZ
dZdZdZddd�Zdd�Zdd	�Zd
d�Zd dd
�Zdd�Zd!dd�Zd"dd�Zdd�Zdd�Zd#dd�Zdd�Zdd�ZdS)$�OptionsNrTcCs�g|_g|_g|_i|_i|_i|_i|_i|_||_|j	dddd|j
�|j	dddd|j
�|j	dddd�tjj
tjj
tjd��}tjj|d	d
�tjj|d
�d
ddd
g}||_i|_x$tjj�D]\}}||jd|<q�WdS)znConstructor.

        Params:
        require_configfile -- whether we should fail on no config file.
        N�h�help�?�
configfilezc:zconfiguration=rZetczsupervisord.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)�selfrI�hererM�kr6r1r1r2�__init__Ys.zOptions.__init__cCsNd}x |jD]}tjj|�r|}PqW|dkrJ|jrJ|jddj|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 pathz, )rMr'r(�existsrI�usager,)rQ�configr(r1r1r2�default_configfilezszOptions.default_configfilecCs@|jd}|jd�dkr&|jd|j�}|jj|�|jd�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)rQ�dummyr>r1r1r2r>�s

zOptions.helpcCs4|jjdt|��|jjd|j�|jd�dS)z2Print a brief error message to stderr and exit(2).z
Error: %s
zFor help, use %s -h
�N)�stderrr_�strr]r`)rQ�msgr1r1r2rV�sz
Options.usagec
Cs�|dk	rd|dk	rtd��|r,|r,td��|rB|jd�rBtd��|rX|jd�rXtd��|fdd�}|r�|r�|jd�|jd�kr�td||f��|�r|d	d
kr�td��|dd�|dd�}
}|dkr�td��d
|
}
|
|jkr�td|
��||f|j|
<|jj|�|�r�|d	d
k�r(td��|}
|
ddk�rF|
dd�}
d|
}
|
|jk�rftd|
��||f|j|
<|jj|�|	�r�||f|j|	<|�r�t||��s�t||d�|j	j||f�|dk	�r�||j
|<|�r�||j|<dS)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|S)Nr1)�arg�flagr1r1r2�<lambda>�szOptions.add.<locals>.<lambda>z&inconsistent short/long options: %r %rr�-z&short option should not start with '-'��z"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')rmrf���rn)�
ValueError�endswithrDrB�appendrCrG�hasattr�setattrrArErF)rQ�name�confnameZshortZlong�handler�defaultZrequiredri�env�key�restr1r1r2rJ�s\ 


zOptions.addcCs0|jj|d�}||kr,t|||�||j|<dS)Nrlrn)rH�getrs)rQ�attr�valueZprioZcurrentr1r1r2�_set�szOptions._setc
)Cs^|dkrtjdd�}|dkr(tjd}|dkrXyddl}|j}Wntk
rVYnX||_||_g|_g|_y$t	j	|dj
|j�|j�\|_|_Wn2t	j
k
r�}z|jt|��WYdd}~XnX|jr�|jr�|jdt|j��x�|jD]�\}}|j|\}}	|	dk	�rXy|	|�}Wn8tk
�rV}
z|jd|||
f�WYdd}
~
XnX|r�|dk	r�t||�dk	�r�|jd|�|j||d�q�Wx�|jj�D]�}|j|\}}	|tjk�r�tj|}|	dk	�ry|	|�}Wn8tk
�r}
z|jd	|||
f�WYdd}
~
XnX|�r�|dk	�r�|j||d��q�W|jdk�rR|j�|_|j�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__)
        Nrlrrmz*positional arguments are not supported: %szinvalid value for %s %r: %sz"conflicting command line option %rrbz'invalid environment value for %s %r: %s)rKrL�__main__�__doc__�	Exceptionr]rZ�options�args�getoptr,rBrC�errorrVrd�positional_args_allowedrDro�getattrr~rG�keysr'rOr@rX�process_config)
rQr�rZr]r�exc�optrhrtrvreZenvvarr}r1r1r2�realize�s^

  
&

 
zOptions.realizec	Cs�|jr|j|�xV|jD]L\}}|r|jd�}|j}x |D]}|dkrHPt||�}q:W|j||d�qWx0|jj�D]"\}}t||�dkrtt	|||�qtWx.|j
j�D] \}}t||�dkr�|j|�q�WdS)z}Process configuration data structure.

        This includes reading config file if necessary, setting defaults etc.
        �.Nr)r@�process_config_filerA�split�
configrootr�r~rErPrsrFrV)	rQ�do_usagertru�parts�obj�partr}�messager1r1r2r�8s"


zOptions.process_configcCsxt|jd�s$tjjtjj|j��|_y|j|j�Wn>tk
rr}z"|rZ|j	t
|��nt|��WYdd}~XnXdS)Nr.)rrr@r'r(r)r*rR�read_configrorVrd)rQr�rer1r1r2r�WszOptions.process_config_filecCstjj|�S)N)r'r(rU)rQr(r1r1r2rUeszOptions.existsr&cCs
t||�S)N)r-)rQ�fn�moder1r1r2r-hszOptions.openc
Cs�g}x�|j�D]�}|j|�sq|jdd�d}|j||d�}|dkrTtd||f��y|j|�}Wn$tk
r�td||f��YnXi}	x*|j|�D]}
|
|kr�|j||
�|	|
<q�W|j|||	f�qW|S)Nrfrlz"section [%s] does not specify a %sz!%s cannot be resolved within [%s])	�sections�
startswithr��sanegetro�import_spec�ImportErrorr�rq)rQ�parserZfactory_keyZsection_prefixZ	factories�sectionrtZfactory_spec�factoryZextrasrSr1r1r2�get_pluginsks(
zOptions.get_pluginscCs0tjjd|�}t|d�r"|j�S|jd�SdS)Nzx=�resolveF)�
pkg_resourcesZ
EntryPoint�parserrr��load)rQ�specZepr1r1r2r��s
zOptions.import_spec)T)	NNNNNNNNN)NNN)T)r&)r9r:r;rKrcr^r`�warnings�uid�gidrLr]r@Z	schemadirr�rRr�rTrXr>rVrJr~r�r�r�rUr-r�r�r1r1r1r2r<Gs@

!

K
F

r<c@seZdZdZdZdZdZdZdZdZ	dZ
dZfZdZ
dZejjZdd�Zdd�Zdd�Zd	d
�Zdd�Zdrdd�Zdd�Zdd�Zdd�Zdsdd�Zdtdd�Zdd�Zdd�Zdd�Z d d!�Z!d"d#�Z"d$d%�Z#d&d'�Z$d(d)�Z%d*d+�Z&d,d-�Z'd.d/�Z(d0d1�Z)d2d3�Z*d4d5�Z+d6d7�Z,d8d9�Z-d:d;�Z.d<d=�Z/d>d?�Z0d@dA�Z1dBdC�Z2dDdE�Z3dFdG�Z4dHdI�Z5dJdK�Z6dLdM�Z7dNdO�Z8dPdQ�Z9dRdS�Z:dTdU�Z;dVdW�Z<dXdY�Z=dZd[�Z>d\d]�Z?d^d_�Z@d`da�ZAdbdc�ZBddde�ZCdfdg�ZDdhdi�ZEdjdk�ZFdudldm�ZGdndo�ZHdpdq�ZIdS)v�
ServerOptionsNFcCs�tj|�t�|_t�|j_|jdddd|j�|jddddddd�|jd	d
dd�|jd
dddtdd�|jddddt�|jddddt	dd�|jddddt
dPd�|jd"d#d$d%td&d�|jd'd(d)d*td+d�|jd,d-d.d/t	d0d�|jd1d2d3d4t
d5d�|jd6d7d8d9ttj�d�|jd:d;d<d=td!d�|jd>d?d@dAtdBd�|jdCdDdEdCddd�|jdFdGdHdFddd�|jdIdJd@dKtdd�|jdLdMdNdLddd�i|_g|_g|_g|_g|_t�|_tj|�|_dS)QNr6�version�nodaemonzsupervisord.nodaemon�nrlr)rirw�userzsupervisord.userzu:zuser=�umaskzsupervisord.umaskzm:zumask=�022)rw�	directoryzsupervisord.directoryzd:z
directory=�logfilezsupervisord.logfilezl:zlogfile=zsupervisord.log�logfile_maxbyteszsupervisord.logfile_maxbyteszy:zlogfile_maxbytes=�2i�logfile_backupszsupervisord.logfile_backupszz:zlogfile_backups=�
�loglevelzsupervisord.loglevelze:z	loglevel=�info�pidfilezsupervisord.pidfilezj:zpidfile=zsupervisord.pid�
identifierzsupervisord.identifierzi:zidentifier=�
supervisor�childlogdirzsupervisord.childlogdirzq:zchildlogdir=�minfdszsupervisord.minfdsza:zminfds=�minprocszsupervisord.minprocsrmz	minprocs=���	nocleanupzsupervisord.nocleanuprS�
strip_ansizsupervisord.strip_ansi�tr!zsupervisord.profile_optionszprofile_options=�silentzsupervisord.silent�si�i )r<rTr8r��supervisordrJr�rrrrrrrd�tempfile�
gettempdir�intr!Z
pidhistory�process_group_configs�parse_criticals�parse_warnings�parse_infos�SignalReceiver�signal_receiverr%ZPoller)rQr1r1r2rT�sZ






zServerOptions.__init__cCs|jjdt�|jd�dS)z-Print version to stdout and exit(0).
        z%s
rN)r^r_�VERSIONr`)rQrar1r1r2r��szServerOptions.versioncOstj||�S)N)r"�	getLogger)rQr��kwargsr1r1r2r��szServerOptions.getLoggercCs"tj�dkr|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��warnr<rX)rQr1r1r2rX�sz ServerOptions.default_configfilec
Osbtj|f|�|�|jj}|jdk	rpyt|j�}Wn,tk
r^}z|j|�WYdd}~XnX||_t	|�|_
|js~|j|_|jr�|j}n|j}|dkr�t
|�|_|jr�|j}n|j}t
|�|_|j|_d|_|j|_}x*dd�|D�D]}	|	d}
d|
|_Pq�W|jdk�rVx@dd�|D�D].}	|	d}|	d}|�sBd	}d
||f|_�q$W|j|_dS)N�syslogcSsg|]}|dtjkr|�qS)�family)�socket�AF_UNIX)�.0rWr1r1r2�
<listcomp>sz)ServerOptions.realize.<locals>.<listcomp>�filez	unix://%scSsg|]}|dtjkr|�qS)r�)r��AF_INET)r�rWr1r1r2r�s�host�portZ	localhostzhttp://%s:%s)r<r�r�r�r�r
rorVr�rr�r�r�r7r��rpcinterface_factories�	serverurl�server_configsr�)
rQrh�kwr�r�rer�r�ZsconfigsrWr(r�r�r1r1r2r��sF




zServerOptions.realizeTcCs"tj||d�|jjj}||_dS)N)r�)r<r�r�r�r�)rQr��newr1r1r2r�$s
zServerOptions.process_configc.sZg|_g|_g|_|jj}d}t|d�sx|j|�s>td|��y|j|d�}d}Wn$t	t
fk
rvtd|��YnXt��|j�_
zhy2y�j|�Wntk
r��j|�YnXWn0tjk
r�}ztt|���WYdd}~XnXWd|�r�|j�Xtj�}|j|d�}|j|j��jd��rX�j|j��jdd	��sNtd
���jdd	�}t||d�}|j�}t|d��r�tj j!tj j"|j#��}nd
}x�|D]�}	tj j$||	�}	t%j%|	�}
|
�s�|jj&d|	��q�x~t'|
�D]r}|jj&d|�y�j(|�Wn2tjk
�r0}ztt|���WYdd}~XnX�jtj j"tj j!|����q�W�q�W�j)�}d|k�rrtd��d|ji���fdd�}
t*|
dd��|_+t*|
dd��|_,|
dd�}|dk�r�d|_-n
t.|�|_-|
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>j?�}t.|
d,|��|_@t;|
d-d*��|_At;|
d.d*��|_B|
d/d0�}t||d/�}tC|�|_Dx&|jDjE�D]\}}||jd1|<�q�W|jF�d2d3�|_G|jH��|_Ix>|jID]4}x,|jJD]"}|jDjK�}|j|jD�||_D�qW�qW|jL��|_Md|_N|S)4NFr.zcould not find config file %sr&Tzcould not read config file %s)rR�host_node_name�include�filesz5.ini file has [include] section, but no files settingz
include.filesrtr�z No file matches via include "%s"z'Included extra file "%s" during parsingr�z..ini file does not include supervisord sectionrRcs.|jdi�}|j��||d<�j||f|�S)N�
expansions)r{�update�
getdefault)r�rwr�r�)�common_expansionsr�r1r2r{qs
z&ServerOptions.read_config.<locals>.getr�ir�r�r�r�r�r�r�zsupervisord.logr��50MBr�r�r�r�r�zsupervisord.pidr�r�r��falser�r�r�r��environmentrmzENV_%szsupervisor.rpcinterface_factoryz
rpcinterface:)Or�r�r�r�r�rrrUror-�IOError�OSError�UnhosedConfigParserrNr��	read_file�AttributeError�readfprZParsingErrorrd�close�platform�noderRr�Zhas_section�expand_hereZ
has_optionr{�expandr�r'r(r*r)rtr,�globrq�sortedr.r�rr�r�r�rr�rr�rr�rr�r�rr�r�r�rr�r�r�r�r�r�r�rr�rPr�r��process_groups_from_parserr��process_configs�copy�server_configs_from_parserr�r!)rQ�fpr��
need_close�whyr�r�r��base�pattern�	filenames�filenamer�r{r�ZtempdirZenviron_strrSr6�group�procrxr1)r�r�r2r�*s�

"




"







zServerOptions.read_configc"&sg}�j�}g}d|ji���fdd�}x�|D]�}|jd�s>q.t|jdd�d�}t||dd��}t||dd	��}	g}
x�|D]�}d
|}d|}
||kr�|
|kr�td||f��||kr�|
|kr�td
||f��||kr�|n|
}|j|�|j	�||t
�}|
j|�q|W|jt|||	|
��q.Wxr|D]j}|jd��s&||k�rF�q&t|jdd�d�}t||dd	��}	|j	�||t
�}|jt|||	|���q&W�x||D�]r}|jd��s��q�|jdd�d}t||dd/��}	t||dd��}|dk�r�td||f��||dd�}y|j
|�}Wn&tk
�r<td||f��YnXdd�t||dd��D�}t|�}|�srtd|��ddlm}g}x>|D]6}t||d�}|dk�r�td||f��|j|��q�Wt||dd��}|�r�td |��|j	�||t�}|jt|||	||||���q�W�x�|D�]�}|jd!��s||k�r>�qt|jdd�d�}t||dd	��}	d"|i}||d#d�}|dk�r�d}nt|�}||d$d�}|dk	�r�t|�}|dk�s�|d%k�r�td&|��||d'd�}|dk	�ryt|�}Wn"tk
�rtd(|��YnX||d)d�}|dk	�r\yt|�}Wn&ttfk
�rZtd*|��YnX||d+d|d,�}|�s~td-|��y|j|||||�} Wn8tk
�r�}!ztd.t|!�|f��WYdd}!~!XnX|j	�||t�}|jt|||	|| ���qW|j�|S)0NrRcs0|jdi�}|j��||d<�j|||f|�S)Nr�)r{r�r�)r�r�rwr�r�)r�r�r1r2r{�s
z5ServerOptions.process_groups_from_parser.<locals>.getzgroup:rfrl�programs�priorityi�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:�buffer_sizer�z*[%s] section sets invalid buffer_size (%d)�result_handlerz&supervisor.dispatchers:default_handlerz!%s cannot be resolved within [%s]cSsg|]}|j��qSr1)�upper)r��xr1r1r2r��sz<ServerOptions.process_groups_from_parser.<locals>.<listcomp>�eventsrmz&[%s] section requires an "events" liner)�
EventTypesz$Unknown event type %s in [%s] events�redirect_stderrr�zx[%s] section sets redirect_stderr=true but this is not allowed because it will interfere with the eventlistener protocolz
fcgi-program:�program_namer��socket_backlogi��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%s in [%s] socketrn)r�rRr�r
r�rrrorq�processes_from_section�
ProcessConfig�extend�ProcessGroupConfigr�r��setZsupervisor.eventsrr�r�EventListenerConfig�EventListenerPoolConfigr
rr�	TypeError�parse_fcgi_socketrd�FastCGIProcessConfig�FastCGIGroupConfig�sort)"rQr��groupsZall_sectionsZhomogeneous_excluder{r��
group_namerrZgroup_processesZprogramZprogram_sectionZfcgi_sectionZ	processesrZ	pool_namer	r
Zpool_event_namesr�pool_eventsZpool_event_nameZ
pool_eventrZfcgi_expansionsZ	proc_user�proc_uidrrrr��
socket_config�er1)r�r�r2r��s�


















&

z(ServerOptions.process_groups_from_parsercCs�|jd�r||dd�}tjj|�s,td|��t|�}|dkr`tj�}|dk	r`||kr`|t|�f}|dkrld}t||||d�S|dk	s�|dk	r�td
��t	j
d|�}|r�|jd	�}	t|jd
��}
t
|	|
|d�Std|��dS)Nzunix://�z+Unix socket path %s is not an absolute pathi�)�ownerr��backlogz*socket_owner and socket_mode params shouldz' only be used with a Unix domain socketztcp://([^\s:]+):(\d+)$rlrb)r(zBad socket format %szQsocket_owner and socket_mode params should only be used with a Unix domain socket)r�r'r(�isabsror7r�rr�re�matchrr�r)rQZsockr#rrrr(r��mr�r�r1r1r2rRs2

zServerOptions.parse_fcgi_socketcCsZy|j||||�Stk
rT}z(|jj||j�}td|||f��WYdd}~XnXdS)Nz%s in section %r (file: %r))�_processes_from_sectionro�section_to_filer{r@)rQr�r�r!�klassr%rr1r1r2rusz$ServerOptions.processes_from_sectionc1"s~|dkrt}g}t|jdd�d�}tj�}|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�|j�j
�d%k�r�d}||d&d�}|dk�r�d}nt|�}||d'd�}|dk	�r�t|�}t||d(d)dd��}|dk�rd*|k�rtd+��|�r|�rtd,���xTt|||�D�]@} �}!|!j| |d-��|!j|j�tt||!d��}"x"|"j�D]\}#}$|$|!d.|#<�qlW||d/d�}%i}&�xdGD]�}#d2|#}'|||'t�}(t|(t��r�t|(|!|'�}(t|(�}(|(|&|'<d3|#})t|||)d��}*|*|&|)<d4|#}+t|||+d5��},|,|&|+<d6|#}-t|||-d��}.|.|&|-<|(tk�rr|jjd7||'|-f�d|&|'<}(d8|&|-<|(tk�r�|,�r�|jjd9||'f��q�W|�r�|&d:tdfk�r�|jjd;|�d|&d:<||d<d|!d=�}/|/dk�r�td>|��||t||!d(�|/|%||	|
|||
||&d?|||&d@|&dA|&dB|&d:|||&dC|&dD|&dE|||||||"|dF�}0|j|0��q,W|j�|S)HNrfrl)rRrr�r!cs2|jdi�}|j��||d<�j||f|�|�S)Nr�)r{r�r�)r�r�r�r�r�)r�r�r1r2r{�s
z2ServerOptions._processes_from_section.<locals>.getri��	autostart�true�autorestartZ
unexpected�	startsecs�startretries��
stopsignalZTERM�stopwaitsecsr��stopasgroupr��killasgroup�	exitcodes�0r�numprocs�numprocs_startrr�rmF)�	do_expand�stdout_capture_maxbytes�stdout_events_enabled�stderr_capture_maxbytes�stderr_events_enabledr�ZAUTOr�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<zENV_%sr�r^rcz
%s_logfilez%s_logfile_backupsz%s_logfile_maxbytesr�z	%s_syslogzfFor [%s], %s=syslog but this is deprecated and will be removed.  Use %s=true to enable syslog instead.TztFor [%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�command)r�z-program section %s does not specify a command�stdout_logfile�stdout_logfile_backups�stdout_logfile_maxbytes�
stdout_syslog�stderr_logfile_backups�stderr_logfile_maxbytes�
stderr_syslog)rtrFr�r�rr0r2r3r4r�rGr?r@rHrIrJrErArBrKrLrMr6r7r8r9r:rr�r�)r^rc)rr
r�r�r�rRrrr rrrr/rr
rro�ranger�rNrr�rPr�
isinstancerrrr�rqr)1rQr�r�r!r/rrr�r{rr0r2r3r4r6r7r8r9r:rr<r=Zenvironment_strZstdout_cmaxbytesZ
stdout_eventsZstderr_cmaxbytesZ
stderr_eventsr�r�r�r�rCrDr�r�rSr6r�ZlogfilesZlf_keyZlf_valZbu_key�backupsZmb_key�maxbytesZsy_keyr�rFZpconfigr1)r�r�r2r-s







z%ServerOptions._processes_from_sectioncCsXg}xN|j�D]B}|j|�r|jdd�}t|�dkr>|d}nd}|j||f�qW|S)Nrfrl)r�r�r��lenrq)rQr��styper�r�r�rtr1r1r2�_parse_servernames+s

z ServerOptions._parse_servernamescCsT|j}||dd�}||dd�}|dk	s.|dk	rJ|dks>|dkrJtd|��||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)rUrV)r�ro)rQr�r�r{rUrVr1r1r2�_parse_username_and_password7sz*ServerOptions._parse_username_and_passwordcCs�g}|j|d�}x�|D]�\}}i}|j}|j|j||��||d<tj|d<||dd�}|dkrltd|��t|�\}	}|	|d<||d<||d<|j|�qW|j|d�}
�x<|
D�]2\}}i}|j}||d	dd
|j	id�}|dkr�td|��|j
�}||d<tj|d<t|�|d	<|j|j||��||d
d�}|dk	�rpyt
|�}Wn"tk
�rltd|��YnXnd}||d
<||dd�}
|
dk	�r�yt|
�}
Wn&ttfk
�r�td|
��YnXnd}
|
|d<||d<|j|�q�W|S)NZinet_http_serverrtr�r�zsection [%s] has no port valuer�r�Zunix_http_serverr�rR)r�zsection [%s] has no file value�chownzInvalid sockchown value %srl�chmodzInvalid chmod value %si�rnrn)rnrn)rTr�r�rWr�r�rorrqrRr/r�r7rrr)rQr�ZconfigsZinet_serverdefsrtr�rWr{r�r�Zunix_serverdefsZsfilerXrYr1r1r2r�Cs^



z(ServerOptions.server_configs_from_parsercCs |jj�|j�|jj�dS)N)r%Zbefore_daemonize�
_daemonizeZafter_daemonize)rQr1r1r2�	daemonizexs
zServerOptions.daemonizecCstj�}|dkr&|jjd�tjd�|jjd�|jr�ytj|j�Wn8tk
r�}z|jj	d|j|f�WYdd}~XnX|jjd|j�tj
d�td�|_t
_t
_tj
d�tdd�|_t
_t
_tj
d	�tdd�|_t
_t
_tj�tj|j�dS)
Nrz"supervisord forked; parent exitingz#daemonizing the supervisord processzcan't chdir into %r: %szset current directory: %rz	/dev/nullrl�wrb)r'�fork�logger�blather�_exitr�r��chdirr��criticalr�r-�stdinrK�	__stdin__r^�
__stdout__rc�
__stderr__�setsidr�)rQ�pid�errr1r1r2rZ}s*
 



zServerOptions._daemonizecCsxtj�}y*t|jd��}|jd|�WdQRXWn*ttfk
r\|jjd|j�YnXd|_	|jj
d|�dS)Nr\z%s
zcould not write pidfile %sTzsupervisord started with pid %s)r'�getpidr-r�r_r�r�r^rb�unlink_pidfiler�)rQrhr0r1r1r2�
write_pidfile�szServerOptions.write_pidfilecCsZx8|jD].\}}|dtjkr|jr|d}|j|�qW|jrL|j|j�|jj�dS)Nr�r�)	�httpserversr�r��unlink_socketfiles�_try_unlinkrkr�r%r�)rQrW�serverZ
socketnamer1r1r2�cleanup�szServerOptions.cleanupcCs(ytj|�Wntk
r"YnXdS)N)r'�unlinkr�)rQr(r1r1r2ro�szServerOptions._try_unlinkcCsng}xN|jD]D\}}|j�x2|j�j�D]"}t|dd�}||kr*|j|�q*WqWx|D]}|j�qZWdS)Nrp)rmr��get_socket_map�valuesr�rq)rQZdispatcher_serversrWrpZ
dispatcherZdispatcher_serverr1r1r2�close_httpservers�s
zServerOptions.close_httpserverscCs|jj�dS)N)r^r�)rQr1r1r2�close_logger�szServerOptions.close_loggercCs`|jj}tjtj|�tjtj|�tjtj|�tjtj|�tjtj|�tjtj|�dS)N)	r��receive�signal�SIGTERM�SIGINT�SIGQUIT�SIGHUP�SIGCHLD�SIGUSR2)rQrwr1r1r2�
setsignals�szServerOptions.setsignalscCs
|jj�S)N)r��
get_signal)rQr1r1r2r��szServerOptions.get_signalcCs�y|j|�|_d|_Wn�tjk
r�}zt|jdtjkrF|jd�nRd}tj	j
|jd�}|dkr~|jd||jdf�n|jd|||jdf�WYdd}~Xn2tk
r�}z|j|jd�WYdd}~XnXdS)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_serversrmrnr�r�r��errnoZ
EADDRINUSErV�	errorcoder{ro)rQr�rr>Z	errornamer1r1r2�openhttpservers�s
$zServerOptions.openhttpserverscCs$d|||f}|jd||jd�}|S)Nz%s-%s---%s-z.log)�suffix�prefix�dir)�
mktempfiler�)rQrtr�Zchannelr�r�r1r1r2�get_autochildlog_names
z#ServerOptions.get_autochildlog_namecCs�|j}tjd|j�}ytj|�}Wn$ttfk
rH|jj	d�dSXx\|D]T}|j
|�rPtjj||�}y|j
|�WqPttfk
r�|jj	d|�YqPXqPWdS)Nz.+?---%s-\S+\.log\.{0,1}\d{0,4}zCould not clear childlog dirzFailed to clean up %r)r�r*�compiler�r'�listdirr�r�r^r�r+r(r,�remove)rQr�Zfnrerr�pathnamer1r1r2�clear_autochildlogdirs

z#ServerOptions.clear_autochildlogdircCstjS)N)�asyncoreZ
socket_map)rQr1r1r2rs!szServerOptions.get_socket_mapcCsBd}x8t||j�D](}ytj|�Wqtk
r8YqXqWdS)N�)rNr�r'r�r�)rQ�startrr1r1r2�cleanup_fds$szServerOptions.cleanup_fdscCstj||�dS)N)r'�kill)rQrhrxr1r1r2r�-szServerOptions.killcCs�ytjdtj�\}}Wnjtk
r�}zN|jd}|tjtjfkrR|jj	d|�|tjkrh|jj
d�d\}}WYdd}~XnX||fS)Nrlrz:waitpid error %r; a process may not be cleaned up properlyzEINTR during reaprn)NN)r'�waitpid�WNOHANGr�r�r�ZECHILD�EINTRr^rbr_)rQrh�stsr��coder1r1r2r�0s


zServerOptions.waitpidc#s>�dkrdSyt��}WnDtk
r\ytj��}Wntk
rNd�SX|d}Yn*Xytj|�}Wntk
r�d|SXtj�}||kr�dS|dkr�dS|d}ttd	��r
|d��fd
d�t	j
�D�}|jd|�ytj|�Wnt
k
�rdSXytj|�Wnt
k
�r.d
SXtj|�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 %rrbzCan't find uid %rrz$Can't drop privilege as nonroot userr5�	setgroupscs g|]}�|dkr|d�qS)r5rbr1)r�Zgrprec)r�r1r2r�nsz1ServerOptions.drop_privileges.<locals>.<listcomp>z&Could not set groups of effective userz(Could not set group id of effective user)r�ro�pwd�getpwnam�KeyError�getpwuidr'r�rr�grpZgetgrall�insertr�r��setgid�setuid)rQr�r�ZpwrecZcurrent_uidr�r r1)r�r2�drop_privilegesHsB

zServerOptions.drop_privilegescCsZ|jdkr$tj�dkrV|jjd�n2|j|j�}|dkrL|jjd|j�n
|j|�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�rqr�r�rV)rQrer1r1r2�set_uid_or_exit�s
zServerOptions.set_uid_or_exitc	
Csg}ttd�r&|jd|jtjdd��ttd�rH|jd|jtjdd��x�|D]�}|d}|d}|d}|d	}|}tj|�\}}||krN|d
krN||kr�|dkr�|}y&tj|||f�|j	jdt
��WqNtjtfk
r�|j
|t
��YqNXqNWd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.)re�min�resourcert�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.r�r�rertrlz)Increased %(name)s limit to %(min_limit)sNrnrn)rrr�rqr�r�r�r�Z	getrlimitZ	setrlimitr��localsr�rorV)	rQZlimits�limitZ	min_limit�resrertZsoftZhardr1r1r2�set_rlimits_or_exit�s:
	

	

z!ServerOptions.set_rlimits_or_exitcCs�d}tj|j�|_|jr.|jr.tj|j|�tj|j|j||j	|j	|j
d�x|jD]}|jj|�qZWx|j
D]}|jj|�qvWx|jD]}|jj|�q�WdS)Nz&%(asctime)s %(levelname)s %(message)s
)ZrotatingrQrP)r"r�r�r^r�r�Z
handle_stdoutZhandle_filer�r�r�r�rbr�r�r�r�)rQ�formatrer1r1r2�make_logger�s"
zServerOptions.make_loggercCsddlm}|||�S)Nr)r�)Zsupervisor.httpr�)rQr�r�r1r1r2r��szServerOptions.make_http_serverscCs(ytj|�Wntk
r"YnXdS)N)r'r�r�)rQ�fdr1r1r2�close_fd�szServerOptions.close_fdcCstj�S)N)r'r])rQr1r1r2r]�szServerOptions.forkcCstj||�S)N)r'�dup2)rQZfrmZtor1r1r2r��szServerOptions.dup2cCstj�S)N)r'�setpgrp)rQr1r1r2r��szServerOptions.setpgrpcCs
tj|�S)N)r'�stat)rQrr1r1r2r��szServerOptions.statcCstj|t|��S)N)r'r_r)rQr��datar1r1r2r_�szServerOptions.writecCstj|||�S)N)r'�execve)rQrrLrxr1r1r2r��szServerOptions.execvecCs&dt_tj|||�\}}tj|�|S)N)r'Z
_urandomfdr�Zmkstempr�)rQr�r�r�r�rr1r1r2r�s
zServerOptions.mktempfilecCstj|�dS)N)r'r�)rQr(r1r1r2r�
szServerOptions.removecCstj|�dS)N)r'r`)rQr�r1r1r2r`
szServerOptions._exitcCstj|�dS)N)r'r�)rQ�maskr1r1r2�setumaskszServerOptions.setumaskcCs2dddg}dtjkr.tjd}|r.|jtj�}|S)z3Return a list corresponding to $PATH, or a default.z/binz/usr/binz/usr/local/bin�PATH)r'rOr��pathsep)rQr(�pr1r1r2�get_paths


zServerOptions.get_pathcCstj�S)N)r'rj)rQr1r1r2�get_pidszServerOptions.get_pidcCst|dkrtd|��nZtj|tj�r4td|��n<tj|tj�d@sVtd|��ntj|tj�spt	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)rQrrL�str1r1r2�check_execv_argsszServerOptions.check_execv_argscCs4|jjd�x"|jjD]}t|d�r|j�qWdS)Nzsupervisord logreopen�reopen)r^r�Zhandlersrrr�)rQrvr1r1r2�
reopenlogs,s
zServerOptions.reopenlogscCsXytj|d�}WnBtk
rR}z&|jdtjtjtjfkr>�d}WYdd}~XnX|S)Nrb�r�i)r'r.r�r�r�ZEWOULDBLOCKZEBADFr�)rQr�r�rr1r1r2�readfd2szServerOptions.readfdcCstj|�dS)N)r'ra)rQr�r1r1r2ra;szServerOptions.chdirc
Csddddddd�}y�tj�\}}|||d<|d<tj�\}}|||d<|d<|rrtj�\}}|||d<|d<xJ|d|d|dfD]0}|dk	r�tj|tj�tjB}	tj|tj|	�q�W|Stk
�r�x"|j�D]}|dk	r�|j|�q�W�YnXdS)	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_stdinrcr^�child_stdoutrc�child_stderrr�rcr^r�rcr�)	r'�pipe�fcntlZF_GETFL�O_NDELAYZF_SETFLr�rtr�)
rQrc�pipesrcr�r^r�r�r��flagsr1r1r2�
make_pipes>s0zServerOptions.make_pipescCs.x(dD] }|j|�}|dk	r|j|�qWdS)Nrcr^rc)rcr^rc)r{r�)rQr��fdnamer�r1r1r2�close_parent_pipes]s

z ServerOptions.close_parent_pipescCs.x(dD] }|j|�}|dk	r|j|�qWdS)Nr�r�r�)r�r�r�)r{r�)rQr�r�r�r1r1r2�close_child_pipescs

zServerOptions.close_child_pipes)T)N)N)T)Jr9r:r;r�Z	sockchownZ	sockchmodr�r�r�Z
passwdfiler�r�rmrkrnr#ZSupervisorStatesZRUNNINGZmoodrTr�r�rXr�r�r�r�rrr-rTrWr�r[rZrlrqrorurvrr�r�r�r�rsr�r�r�r�r�r�r�r�r�r]r�r�r�r_r�r�r�r`r�r�r�r�r�r�rar�r�r�r1r1r1r2r��s�0@
*$


,54
		9<		
	
r�c@sHeZdZdZdZdZdZdZdZdZ	dd�Z
dd�Zdd�Zd	d
�Z
dS)�
ClientOptionsrlNcCs�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�|jdddd�|jdddd�|jdddd�dS) NF)rIr�r)�DefaultControllerPluginrw�interactivezsupervisorctl.interactive�irl)rirw�promptzsupervisorctl.prompt)rwr�zsupervisorctl.serverurlzs:z
serverurl=zhttp://localhost:9001rUzsupervisorctl.usernamezu:z	username=rVzsupervisorctl.passwordzp:z	password=�historyzsupervisorctl.history_filezr:z
history_file=)r<rTr8r��
supervisorctlr�r�r�rUrV�history_fileZsupervisor.supervisorctlr��plugin_factoriesrJr)rQr��default_factoryr1r1r2rTss(









zClientOptions.__init__cOs"tj|f|�|�|jsd|_dS)Nrl)r<r�r�r�)rQrhr�r1r1r2r��szClientOptions.realizec	Cs�|jj}d}t|d�sxtjjt|��|_|j|�s>t	d|��y|j
|d�}d}Wn$ttfk
rvt	d|��YnXt
�}|j|_d|_y|j|�Wntk
r�|j|�YnX|r�|j�|j�}d|kr�t	d��|jd	d
d|jid�}|jd
��rt|dd��}d|}||_|jd|j�|_|jd|j�|_|jd|j�|_|jd|jd|jid�}|�r�t|�}||_||_nd|_d|_|j|j|dd�7_|S)NFr.zcould not find config file %sr&Tzcould not read config file %sr�z0.ini file does not include supervisorctl sectionr�zhttp://localhost:9001rR)r�zunix://r&z	unix://%sr�rUrVr�zsupervisor.ctl_factoryz
ctlplugin:)r�r�rrr'r(r*r7rRrUror-r�r�r�rNr��	mysectionr�r�r�r�r�r�r�r�r�rUrVr�r�r�)	rQr�r�r�r�r�r�r(r�r1r1r2r��sZ




zClientOptions.read_configcCstjdtj|j|j|j�d�S)Nzhttp://127.0.0.1)Z	transport)rZServerProxyr$ZSupervisorTransportrUrVr�)rQr1r1r2�getServerProxy�s
zClientOptions.getServerProxy)r9r:r;r�r�r�r�rUrVr�rTr�r�r�r1r1r1r2r�is9r�c@sPeZdZdZdd�Zddd�Zdd�Zed	ifd
d�Zeifdd
�Z	dd�Z
dS)r�r�cOsHts$d|krd|d<d|kr$d|d<tjj|f|�|�i|_i|_dS)NZinline_comment_prefixes�;�#�strictF)r�r�)rr�RawConfigParserrTr.r�)rQr�r�r1r1r2rT�szUnhosedConfigParser.__init__�<string>cCs4ytjj|||�Stk
r.|jt|��SXdS)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.N)rr��read_stringr�r�r)rQ�string�sourcer1r1r2r��s

zUnhosedConfigParser.read_stringcKstt|t�r|g}g}xZ|D]R}|jj�}|jtjj||gf|��t|j�t|�}x|D]}||j	|<qZWqW|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.
        )
rOrZ	_sectionsr�rrr�r.�	frozensetr.)rQrr�Zok_filenamesrZ
sections_origZdiffr�r1r1r2r.�s



zUnhosedConfigParser.readTcCs|y|j||�}Wn&tjk
r6|tkr.�n|}YnX|rxt|t�rxtt|jj	��t|j	���}t
||d||f�}|S)Nz%s.%s)r{rZ
NoOptionError�_markerrOr�dict�listr�rPr�)rQr��optionrwr>r�ZoptvalZcombined_expansionsr1r1r2r�	s
zUnhosedConfigParser.sanegetcKs|j|j|f||d�|��S)N)rwr�)r�r�)rQr�rwr�r�r1r1r2r�szUnhosedConfigParser.getdefaultcCsdd}xZ|j�D]N}xH|j|�D]:\}}||kr|dk	s>td��|j||�}|j|||�qWqWdS)Nz%(here)szhere has not been set to a path)r�rP�AssertionErrorr\r)rQrRZHERE_FORMATr�ryr}r1r1r2r� szUnhosedConfigParser.expand_hereN)r�)r9r:r;r�rTr�r.r�r�r�r�r1r1r1r2r��s
	r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�ConfigcCs|j|�S)N)�__eq__)rQ�otherr1r1r2�__ne__+sz
Config.__ne__cCs$|j|jkr|j|jkS|j|jkS)N)rrt)rQr�r1r1r2�__lt__.sz
Config.__lt__cCs$|j|jkr|j|jkS|j|jkS)N)rrt)rQr�r1r1r2�__le__4sz
Config.__le__cCs$|j|jkr|j|jkS|j|jkS)N)rrt)rQr�r1r1r2�__gt__:sz
Config.__gt__cCs$|j|jkr|j|jkS|j|jkS)N)rrt)rQr�r1r1r2�__ge__@sz
Config.__ge__cCsd|jt|�|jfS)Nz<%s instance at %s named %s>)�	__class__�idrt)rQr1r1r2�__repr__FszConfig.__repr__N)	r9r:r;r�r�r�r�r�r�r1r1r1r2r�*sr�c@s�eZdZddddddddd	d
ddd
dddddddddddddddgZddgZdd �Zd!d"�Zd#d$�Zd%d&�Zd,d(d)�Z	d*d+�Z
d'S)-rrtr�rFr�r�rr0r2r3r4rGr?r@rJrHrIrErArKrLrBrMr6r7r8r9r:rr�r�cKsN||_x|jD]}t||||�qWx"|jD]}t|||j|d��q.WdS)N)r��req_param_namesrs�optional_param_namesr{)rQr�Zparamsrtr1r1r2rTXs
zProcessConfig.__init__cCsZt|t�sdSxF|j|jD]6}tt||�t||�gkr:qt||�t||�krdSqWdS)NFT)rOrr�r�rr�)rQr�rtr1r1r2r�_s
zProcessConfig.__eq__cCs4|jdk	r*|jjd�}|dk	r*|jtj�S|jj�S)z|Return a list corresponding to $PATH that is configured to be set
        in the process environment, or the system default.Nr�)r�r{r�r'r�r�r�)rQr(r1r1r2r�ks

zProcessConfig.get_pathcCsJ|jj}|jj}|j}|jtkr.|||d�|_|jtkrF|||d�|_dS)Nr^rc)r�r�r�rtrGrrE)rQZget_autonameZsidrtr1r1r2�create_autochildlogsts

z"ProcessConfig.create_autochildlogsNcCsddlm}||�}||_|S)Nr)�
Subprocess)�supervisor.processrr)rQrr�processr1r1r2�make_process~szProcessConfig.make_processcCs�|j}|jj|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
|dk	rv|
j}||||�||<|dk	r�|
j	}||||�||<|dk	r�|	|d|�||<||fS)Nr^rcrcr)�POutputDispatcher)�PInputDispatcher)r
)
rr�r��supervisor.dispatchersrrr�r
ZProcessCommunicationStdoutEvent�ProcessCommunicationStderrEvent)rQr�
use_stderrr��	stdout_fd�	stderr_fd�stdin_fd�dispatchersrrr
�etyper1r1r2�make_dispatchers�s zProcessConfig.make_dispatchers)N)r9r:r;r�r�rTr�r�r�rrr1r1r1r2rJs"	

rc@seZdZdd�ZdS)rc
Cs�d}|jj|�}|d|d|d}}}i}ddlm}ddlm}	ddlm}
dd	lm}|dk	rx||d|�||<|dk	r�|j}|
|||�||<|dk	r�|	|d|�||<||fS)
NTr^rcrcr)�PEventListenerDispatcher)r)r)r
)	r�r�rrrrr�r
r)
rQrrr�r	r
rrrrrr
r
r1r1r2r�s"
z$EventListenerConfig.make_dispatchersN)r9r:r;rr1r1r1r2r�src@seZdZddd�Zdd�ZdS)rNcCs.|dkrtd��ddlm}||�}||_|S)Nz FastCGI programs require a groupr)�FastCGISubprocess)�NotImplementedErrorrrr)rQrrrr1r1r2r�sz!FastCGIProcessConfig.make_processcCs4tj||�\}}|d}|dk	r,||j�||fS)Nrc)rrr�)rQrrr�rr1r1r2r�s
z%FastCGIProcessConfig.make_dispatchers)N)r9r:r;rrr1r1r1r2r�s
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs||_||_||_||_dS)N)r�rtrr�)rQr�rtrr�r1r1r2rT�szProcessGroupConfig.__init__cCsBt|t�sdS|j|jkrdS|j|jkr.dS|j|jkr>dSdS)NFT)rOrrtrr�)rQr�r1r1r2r��s
zProcessGroupConfig.__eq__cCsx|jD]}|j�qWdS)N)r�r�)rQrWr1r1r2�after_setuid�szProcessGroupConfig.after_setuidcCsddlm}||�S)Nr)�ProcessGroup)rr)rQrr1r1r2�
make_group�szProcessGroupConfig.make_groupN)r9r:r;rTr�rrr1r1r1r2r�s
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCs.||_||_||_||_||_||_||_dS)N)r�rtrr�r	r"r
)rQr�rtrr�r	r"r
r1r1r2rT�sz EventListenerPoolConfig.__init__cCs^t|t�sdS|j|jkrZ|j|jkrZ|j|jkrZ|j|jkrZ|j|jkrZ|j|jkrZdSdS)NFT)rOrrtrr�r	r"r
)rQr�r1r1r2r��s
zEventListenerPoolConfig.__eq__cCsx|jD]}|j�qWdS)N)r�r�)rQrWr1r1r2r�sz$EventListenerPoolConfig.after_setuidcCsddlm}||�S)Nr)�EventListenerPool)rr)rQrr1r1r2r�sz"EventListenerPoolConfig.make_groupN)r9r:r;rTr�rrr1r1r1r2r�s
rc@s$eZdZdd�Zdd�Zdd�ZdS)rcCstj|||||�||_dS)N)rrTr$)rQr�rtrr�r$r1r1r2rT�szFastCGIGroupConfig.__init__cCs*t|t�sdS|j|jkrdStj||�S)NF)rOrr$rr�)rQr�r1r1r2r�s

zFastCGIGroupConfig.__eq__cCsddlm}||�S)Nr)�FastCGIProcessGroup)rr)rQrr1r1r2rszFastCGIGroupConfig.make_groupN)r9r:r;rTr�rr1r1r1r2r�s
	rc	Cs�t|�}t|�}y�t|d���}||krt|r2td��|jdd�|j�}t||�}|dkr^d}|j|�|j|�}n@||kr�td��|dkr�|j|�|j�}n|j|�|j|�}WdQRXWn ttfk
r�td��YnX|S)zJ Read length bytes from the file named by filename starting at
    offset �rbZ
BAD_ARGUMENTSrrbNZFAILED)	�absr-ro�seek�tellr�r.r�r�)	r�offset�lengthZ	absoffsetZ	abslengthr0�sz�posr�r1r1r2�readFiles0



rcCs�y�t|d���}d}|jdd�|j�}|||kr>d}|d}|||krb||dkrZd}||}|dkrnd}|dkrzd}|dkr�d}n|j|�|j|�}|}t|�||gSQRXWnttfk
r�d	|dgSXdS)
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.
    rFrrbTrlr�Nrm)r-rrr.rr�r�)rrrr0Zoverflowrr�r1r1r2�tailFile7s0

r cCs�tj|�r(tj|�d@}d|}||fStj|�rztj|�}dt|�}ttd�r^tj|�}n|d@}|rr|d7}d
|fSd|}d|fSd	S)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.
    i��zexit status %szterminated by %s�	WCOREDUMP�z (core dumped)rlz unknown termination cause 0x%04xNrnrn)r'�	WIFEXITED�WEXITSTATUS�WIFSIGNALED�WTERMSIG�signamerrr!)r�Zesre�sigZiscorer1r1r2�decode_wait_status`s



r)cCs tdkrt�tj|�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(r1r1r2r'|sr'cCsTi}xFtjj�D]8\}}t|dd�}|dkr.q|d�r|d�r|||<qW|adS)Nr�ZSIGZSIG_)rx�__dict__rPr�r*)�drSr6Zk_startswithr1r1r2r+�sr+c@s$eZdZdd�Zdd�Zdd�ZdS)r�cCs
g|_dS)N)�_signals_recvd)rQr1r1r2rT�szSignalReceiver.__init__cCs||jkr|jj|�dS)N)r.rq)rQr(�framer1r1r2rw�s
zSignalReceiver.receivecCs|jr|jjd�}nd}|S)Nr)r.�pop)rQr(r1r1r2r��szSignalReceiver.get_signalN)r9r:r;rTrwr�r1r1r1r2r��sr�cCs�y||Stk
r\}z8t|j��}|j�td||t|�dj|�f��WYdd}~Xn8tk
r�}ztd||t|�f��WYdd}~XnXdS)NzYFormat string %r for %r contains names (%s) which cannot be expanded. Available names: %sz, z.Format string %r for %r is badly formatted: %s)r�r�r�rrordr,r�)r�r�rtZexZ	availabler1r1r2r��s*r�cCs||kr|}nd||f}|S)Nz%s:%sr1)r!rCrtr1r1r2�
make_namespec�sr1cCsF|jdd�}t|�dkr4|\}}|s.|dkr>d}n
||}}||fS)Nrfrlrb�*)r�rR)Znamespec�namesr!rCr1r1r2�split_namespec�s
r4c@seZdZdZdS)�ProcessExceptionz@ Specialized exceptions used when attempting to start a process N)r9r:r;r�r1r1r1r2r5�sr5c@seZdZdZdS)�
BadCommandz5 Indicates the command could not be parsed properly. N)r9r:r;r�r1r1r1r2r6�sr6c@seZdZdZdS)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. N)r9r:r;r�r1r1r1r2r��sr�c@seZdZdZdS)r�zR Indicates that the filespec cannot be executed because it could not
    be found N)r9r:r;r�r1r1r1r2r��sr�c@seZdZdZdS)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. N)r9r:r;r�r1r1r1r2r��sr�)\r�r�r'rKr�r�rxr*r�r�r�r�r�r�r�r�r�Zsupervisor.compatrrrrrrrZsupervisor.medusar	r�Zsupervisor.datatypesr
rrr
rrrrrrrrrrrrrrrrrrr r!r�r"r#r$r%r3r�r7r8r<r�r�r�r�r��objectr�rrrrrrrr r)r*r'r+r�r�r1r4r�r5r6r�r�r�r1r1r1r2�<module>s�JcmR L!")


© 2025 UnknownSec
Courses | Anyleson - Learning Platform
INR (₹)
India Rupee
$
United States Dollar

Courses

17 Courses
Course
Full Stack Web Development

Full Stack Web Development

in Web Development
83:20 Hours
10 Oct 2024
₹28,318.82
Course
Installment and Secure Host

Installment and Secure Host

in Business Strategy
5.00
1:30 Hours
16 Mar 2023
₹118
Course
New Update Features

New Update Features

in Language
4.00
1:30 Hours
21 Jun 2022
Free
Not conducted
Bestseller
New In-App Live System

New In-App Live System

in Communications
5.00
2:30 Hours
1 Mar 2026
₹11.80
Featured
New Learning Page

New Learning Page

in Lifestyle
5.00
3:30 Hours
1 Mar 2022
Free
Finished
How to Travel Around the World

How to Travel Around the World

in Lifestyle
5.00
2:30 Hours
2 Mar 2022
₹29.50

Type

More options