HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/self/root/lib/python3.6/site-packages/supervisor/__pycache__/supervisord.cpython-36.pyc
3

�k�`�8�@s�dZddlZddlZddlZddlmZddlmZddl	m
Z
ddl	mZddl	mZddl
mZdd	lmZdd
lmZGdd�d�Zd
d�Zdd�Zddd�Zdd�Zedkr�e�dS)a�supervisord -- run a set of applications as daemons.

Usage: %s [options]

Options:
-c/--configuration FILENAME -- configuration file path (searches if not given)
-n/--nodaemon -- run in the foreground (same as 'nodaemon=true' in config file)
-s/--silent -- no logs to stdout (maps to 'silent=true' in config file)
-h/--help -- print this usage message and exit
-v/--version -- print supervisord version number and exit
-u/--user USER -- run supervisord as this user (or numeric uid)
-m/--umask UMASK -- use this umask for daemon subprocess (default is 022)
-d/--directory DIRECTORY -- directory to chdir to when daemonized
-l/--logfile FILENAME -- use FILENAME as logfile path
-y/--logfile_maxbytes BYTES -- use BYTES to limit the max size of logfile
-z/--logfile_backups NUM -- number of backups to keep when max bytes reached
-e/--loglevel LEVEL -- use LEVEL as log level (debug,info,warn,error,critical)
-j/--pidfile FILENAME -- write a pid file for the daemon process to FILENAME
-i/--identifier STR -- identifier used for this instance of supervisord
-q/--childlogdir DIRECTORY -- the log directory for child process logs
-k/--nocleanup --  prevent the process from performing cleanup (removal of
                   old automatic child log files) at startup.
-a/--minfds NUM -- the minimum number of file descriptors for start success
-t/--strip_ansi -- strip ansi escape codes from process output
--minprocs NUM  -- the minimum number of processes available for start success
--profile_options OPTIONS -- run supervisord under profiler and output
                             results based on OPTIONS, which  is a comma-sep'd
                             list of 'cumulative', 'calls', and/or 'callers',
                             e.g. 'cumulative,callers')
�N)�asyncore_25)�	as_string)�
ServerOptions)�decode_wait_status)�signame)�events)�SupervisorStates)�getProcessStateDescriptionc@s�eZdZdZdZdZdZdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd"dd�Zd#dd�Zdd�Zd d!�ZdS)$�
SupervisorFrNcCs||_i|_i|_dS)N)�options�process_groups�ticks)�selfr�r�!/usr/lib/python3.6/supervisord.py�__init__6szSupervisor.__init__cCsV|jjs|jj�|jj�|jjr.|jj�|jj�|jjsJ|jj�|j�dS)N)	r�firstZcleanup_fdsZset_uid_or_exitZset_rlimits_or_exitZmake_loggerZ	nocleanupZclear_autochildlogdir�run)rrrr�main;s




zSupervisor.mainc
Cs�i|_d|_tj�zdx|jjD]}|j|�q W|jj|�|jj�|jj	rd|jj
rd|jj�|jj�|j
�Wd|jj�XdS)N)r�stop_groupsr�clearr�process_group_configs�add_process_groupZopenhttpserversZ
setsignalsZnodaemonrZ	daemonizeZ
write_pidfile�
runforeverZcleanup)r�configrrrrPs


zSupervisor.runcs�|jj}dd�|jj�D�}ttdd�|D�|���ttdd�|D�|����fdd�|D�}�fdd�|D�}�fdd�|D�}|||fS)NcSsg|]
}|j�qSr)r)�.0�grouprrr�
<listcomp>dsz-Supervisor.diff_to_active.<locals>.<listcomp>cSsg|]
}|j�qSr)�name)r�cfgrrrrfscSsg|]
}|j�qSr)r)rrrrrrgscsg|]}|j�kr|�qSr)r)r�cand)�curdictrrriscsg|]}|j�kr|�qSr)r)rr )�newdictrrrjscs"g|]}|�j|j|�kr|�qSr)�getr)rr )r!rrrls)rrr�values�dict�zip)r�newZcurZaddedZremovedZchangedr)r!r"r�diff_to_activebszSupervisor.diff_to_activecCs>|j}||jkr:|j�|j�|j|<tjtj|��dSdS)NTF)rrZafter_setuidZ
make_groupr�notifyZProcessGroupAddedEvent)rrrrrrrqs
zSupervisor.add_process_groupcCs<|j|j�rdS|j|j�|j|=tjtj|��dS)NFT)r�get_unstopped_processesZ
before_removerr)ZProcessGroupRemovedEvent)rrrrr�remove_process_groupzszSupervisor.remove_process_groupcCs*i}x |jj�D]}|j|j��qW|S)N)rr$�updateZget_dispatchers)rZprocess_maprrrr�get_process_map�szSupervisor.get_process_mapcCs�g}x |jj�D]}|j|j��qW|r�tj�}||jdkr�dd�|D�}dj|�}|jjj	d|�||_x2|D]*}t
|j��}|jjjd|j
j|f�qvW|S)N�cSsg|]}t|jj��qSr)rrr)r�prrrr�sz.Supervisor.shutdown_report.<locals>.<listcomp>z, zwaiting for %s to diez%s state: %s)rr$�extendr*�time�lastshutdownreport�joinr�logger�infor	�	get_state�blatherrr)rZ	unstoppedr�now�namesZnamestr�proc�staterrr�shutdown_report�s

zSupervisor.shutdown_reportcCs|jr|jdj�dS)N����)rZstop_all)rrrr�ordered_stop_groups_phase_1�sz&Supervisor.ordered_stop_groups_phase_1cCs(|jr$|jj�}|j�r$|jj|�dS)N)r�popr*�append)rrrrr�ordered_stop_groups_phase_2�s
z&Supervisor.ordered_stop_groups_phase_2c
Cs\tjtj��d}|jj�}�x8i}|j|�|j|j��t|jj	��}|j
�|jjtj
kr�|js�d|_|dd�|_tjtj��|j�|j�s�tj�x@|j�D]4\}}|j�r�|jjj|�|j�r�|jjj|�q�W|jjj|�\}}x�|D]|}||kr�y>||}|jjjd|d�|j�|j��s@|jjj|�Wq�tjk
�r\�Yq�||j �Yq�Xq�Wx�|D]�}||k�r~y>||}|jjjd|d�|j!�|j��s�|jjj"|�Wn0tjk
�r��Yn||j �YnX�q~Wx|D]}	|	j#��qW|j$�|j%�|j&�|jjtj
k�rJ|j'�|jj(r Pq WdS)Nr=Tz#read event caused by %(dispatcher)r)�
dispatcherz$write event caused by %(dispatcher)r))rr)ZSupervisorRunningEventrZget_socket_mapr,r-�listrr$�sort�moodrZRUNNING�stoppingrZSupervisorStoppingEventr?r<�asyncore�ExitNow�items�readableZpollerZregister_readable�writableZregister_writableZpollr4r7Zhandle_read_eventZunregister_readableZhandle_errorZhandle_write_eventZunregister_writableZ
transition�reap�
handle_signal�tickrB�test)
rZtimeoutZ
socket_mapZcombined_mapZpgroups�fdrC�r�wrrrrr�sx







zSupervisor.runforevercCs~|dkrtj�}xhtjD]^}|j}|jj|�}|dkrJt||�}|j|<t||�}||kr||j|<tj|||��qWdS)zo Send one or more 'tick' events when the timeslice related to
        the period for the event type rolls over N)r1rZTICK_EVENTS�periodr
r#�	timeslicer))rr8ZeventrTZ	last_tickZ	this_tickrrrrO�s

zSupervisor.tickcCs�|dkrdS|jj�\}}|r�|jjj|d�}|dkrZt|�\}}|jjjd||f�n|j||�|jj|=|s�|jd|dd�dS)N�dzreaped unknown pid %s (%s)Fr=)�once�recursionguard)	r�waitpidZ
pidhistoryr#rr4r5ZfinishrM)rrWrX�pid�stsZprocess�_�msgrrrrMs
zSupervisor.reapcCs|jj�}|�r|tjtjtjfkrF|jjjdt|��t	j
|j_n�|tjkr�|jjt	j
krv|jjjdt|��n |jjjdt|��t	j
|j_n�|tjkr�|jjjdt|��n`|tjk�r|jjjdt|��|jj�x2|jj�D]}|j�q�Wn|jjjdt|��dS)Nz#received %s indicating exit requestz<ignored %s indicating restart request (shutdown in progress)z&received %s indicating restart requestz#received %s indicating a child quitz)received %s indicating log reopen requestzreceived %s indicating nothing)rZ
get_signal�signal�SIGTERM�SIGINT�SIGQUITr4�warnrrZSHUTDOWNrF�SIGHUP�
RESTARTING�SIGCHLD�debug�SIGUSR2r5Z
reopenlogsrr$r7)rZsigrrrrrN s0



zSupervisor.handle_signalcCs|jjS)N)rrF)rrrrr6<szSupervisor.get_state)N)Fr)�__name__�
__module__�__qualname__rGr2rrrrrr(rr+r-r<r?rBrrOrMrNr6rrrrr
0s&	
P

r
cCst|||�S)N)�int)rTZwhenrrrrU?srUcCs�yddl}Wntk
r(ddl}YnXddl}ddl}|j�\}}	zN|j||||	�|j|	�}
|
j�|
j	|ptd�|r�|
j
d�n
|
jd�Wdtj
|	�XdS)Nr�
cumulative�callsr1g333333�?)rlrmr1)ZcProfile�ImportError�profile�pstats�tempfileZmkstempZrunctxZStatsZ
strip_dirsZ
sort_statsZ
print_callersZprint_stats�os�remove)�cmd�globals�locals�
sort_order�callersrorprqrQ�fnZstatsrrrroCs 
roFcCs�tjdkstd��d}xxt�}|j|td�||_||_|jr^|j\}}t	dt
�t�||�nt|�|j
�|j�d}|s�|jtjkrPqWdS)N�posixz)This code makes Unix-specific assumptionsT)�doczgo(options)F)rrr�AssertionErrorrZrealize�__doc__rrPZprofile_optionsrorurv�goZclose_httpserversZclose_loggerrFrrd)�argsrPrrrwrxrrrrZs 
rcCs0t|�}y|j�Wntjk
r*YnXdS)N)r
rrHrI)r�drrrr~ns
r~�__main__)NF)r}rrr1r^Zsupervisor.medusarrHZsupervisor.compatrZsupervisor.optionsrrrZ
supervisorrZsupervisor.statesrr	r
rUrorr~rhrrrr�<module> s(