
    \d	                     ^    d Z ddlmZmZ ddlmZ ddlmZ  G d dej                  Zd Z	dS )	z>
Support for creating a service which runs a process monitor.
    )ListSequence)usage)ProcessMonitorc                       e Zd ZU dZdZddddegddd	d
egddddegddddeggZg Zee	e
                  ed<   dZd Zd ZdS )OptionszF
    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 10c                     || d<   dS )zQ
        Grab the command line that is going to be started and monitored
        argsN )selfr   s     9lib/python3.11/site-packages/twisted/runner/procmontap.py	parseArgszOptions.parseArgsI   s     V    c                 `    t          | d                   dk     rt          j        d          dS )z)
        Check for dependencies.
        r   r   z$Please specify a process commandlineN)lenr   
UsageError)r   s    r   postOptionszOptions.postOptionsO   s5     tF|q  "#IJJJ ! r   N)__name__
__module____qualname____doc__synopsisfloatoptParametersr   r   r   str__annotations__longdescr   r   r   r   r   r   r      s           /H B	
 ) 	
  	
  	
7$ML %'Hd8C=!&&&	H  K K K K Kr   r   c                     t                      }| d         |_        | d         |_        | d         |_        | d         |_        |                    d                    | d                   | d                    |S )Nr	   r   r   r    r   )r   r	   killTimeminRestartDelaymaxRestartDelay
addProcessjoin)configss     r   makeServicer2   W   sn    A%AK
#AJ01A01ALL&.))6&>:::Hr   N)
r"   typingr   r   twisted.pythonr   twisted.runner.procmonr   r   r2   r   r   r   <module>r6      s   
  " ! ! ! ! ! ! !             1 1 1 1 1 1EK EK EK EK EKem EK EK EKP	 	 	 	 	r   