
    h	                     l    S r SSKJrJr  SSKJr  SSKJr   " S S\R                  5      rS\S\4S	 jr	g
)z>
Support for creating a service which runs a process monitor.
    )ListSequence)usage)ProcessMonitorc                       \ rS rSr% SrSrSSSS\/SS	S
S\/SSSS\/SSSS\//r/ r\	\
\      \S'   SrS\SS4S jrSS jrSrg)Options   z>
Define the options accepted by the I{twistd procmon} plugin.
z[procmon options] commandline	thresholdt   zRHow long a process has to live before the death is considered instant, in seconds.killtimek   zpHow long a process being killed has to get its affairs in order before it gets killed with an unmaskable signal.minrestartdelaymzLThe minimum time (in seconds) to wait before attempting to restart a processmaxrestartdelayMi  zLThe maximum time (in seconds) to wait before attempting to restart a processoptFlagsa`  procmon runs processes, monitors their progress, and restarts them when they
die.

procmon will not attempt to restart a process that appears to die instantly;
with each "instant" death (less than 1 second, by default), it will delay
approximately twice as long before restarting it. A successful run will reset
the counter.

Eg twistd procmon sleep 10argsreturnNc                     XS'   g)zA
Grab the command line that is going to be started and monitored
r   N )selfr   s     `/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/runner/procmontap.py	parseArgsOptions.parseArgsI   s     V    c                 T    [        U S   5      S:  a  [        R                  " S5      eg)z
Check for dependencies.
r   r   z$Please specify a process commandlineN)lenr   
UsageError)r   s    r   postOptionsOptions.postOptionsO   s,     tF|q ""#IJJ !r   r   )r   N)__name__
__module____qualname____firstlineno____doc__synopsisfloatoptParametersr   r   r   str__annotations__longdescr   r!   __static_attributes__r   r   r   r   r      s     /H B	
 ) 	
  	
  	
7$ML %'Hd8C=!&	Hs t Kr   r   configr   c                     [        5       nU S   Ul        U S   Ul        U S   Ul        U S   Ul        UR                  SR                  U S   5      U S   5        U$ )Nr
   r   r   r    r   )r   r
   killTimeminRestartDelaymaxRestartDelay
addProcessjoin)r/   ss     r   makeServicer8   W   sb    A%AK
#AJ01A01ALL&.)6&>:Hr   N)
r'   typingr   r   twisted.pythonr   twisted.runner.procmonr   r   r8   r   r   r   <module>r<      s=   
 "   1EKemm EKP	 	N 	r   