a
    2`/b                     @   s:  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dlmZmZ d dlmZ d dlmZmZ edZejddd	Zejedd
dejdedddejdedddejdedddejdedddejdedddejdedddejdedddejdedddejdeddd d!ejd"d#dd$d%d&ejd'd(dd$d)d&ejd*d$d+d,ejd-edd.dejd/ed$dd0d!ejd1edd2dejd3edd4dejd5eddd6d7ejd8d9ejed:ejd;ded<d=e  d>d? Z!d@dA Z"e#dBkr6e"  dS )C    N)IOLoop)	Scheduler)check_python_3install_signal_handlers)validate_preload_argv)enable_proctitle_on_childrenenable_proctitle_on_currentzdistributed.schedulerT)existsZresolve_path)Zignore_unknown_options)Zcontext_settingsz--host z"URI, IP or hostname of this server)typedefaulthelpz--portzServing portz--interfacez0Preferred network interface like 'eth0' or 'ib0'z
--protocolzProtocol like tcp, tls, or ucxz--tls-ca-filez'CA cert(s) file for TLS (in PEM format)z
--tls-certz(certificate file for TLS (in PEM format)z	--tls-keyz(private key file for TLS (in PEM format)z--bokeh-portz$Deprecated.  See --dashboard-addressz--dashboard-addressz:8787z4Address on which to listen for diagnostics dashboard)r   r   Zshow_defaultr   z--dashboard/--no-dashboard	dashboardFz+Launch the Dashboard [default: --dashboard])r   requiredr   z--bokeh/--no-bokehbokehz,Deprecated.  See --dashboard/--no-dashboard.z--show/--no-showzShow web UI [default: --show])r   r   z--dashboard-prefixzPrefix for the dashboard appz--use-xheadersz<User xheaders in dashboard app for ssl termination in headerz
--pid-filezFile to write the process PIDz--scheduler-filezFile to write connection information. This may be a good way to share connection information if your cluster is on a shared network file system.z	--preloadz[Module that should be loaded by the scheduler process  like "foo.bar" or "/path/to/foo.py".)r   ZmultipleZis_eagerr   Zpreload_argv)nargsr   callbackz--idle-timeoutz4Time of inactivity after which to kill the scheduler)r   r   r   c              
      s  t  \}}}t |d |d |d  t  t  |d urNtd|  |}|d urdtd |}|d u r| r|td| sd}dd d|	fd	|
fd
|ffD }| s|	s|
s|rd}  rt	 d"}|
tt  W d    n1 s0    Y   fdd}t| tjdrRdd l}||j\}}t||d }||j||f t }td tf ||| ||||d|td t| fdd}z$|| W   tdj  n  tdj  0 d S )N   zkThe --bokeh-port flag has been renamed to --dashboard-address. Consider adding ``--dashboard-address :%d`` zLThe --bokeh/--no-bokeh flag has been renamed to --dashboard/--no-dashboard. z:\diR"  c                 S   s   i | ]\}}|d ur||qS N ).0kvr   r   =lib/python3.9/site-packages/distributed/cli/dask_scheduler.py
<dictcomp>   s   zmain.<locals>.<dictcomp>tls_ca_fileZtls_scheduler_certZtls_scheduler_keyztls://wc                      s   t j rt   d S r   )ospathr	   remover   )pid_filer   r   del_pid_file   s    zmain.<locals>.del_pid_fileZlinuxr      z/-----------------------------------------------)loopZsecurityhostportr   dashboard_addressZhttp_prefixc                      s    I d H     I d H  d S r   )finishedr   )	schedulerr   r   run   s    
zmain.<locals>.runzEnd scheduler at %r)!gcZget_thresholdZset_thresholdr   r   warningswarnresearchopenwritestrr   getpidatexitregistersysplatform
startswithresourceZ	getrlimitZRLIMIT_NOFILEmaxZ	setrlimitr   currentloggerinfor   r   Zrun_syncstopZaddress)r%   r&   Z
bokeh_portZshowr   r   Zdashboard_prefixZuse_xheadersr!   r   Ztls_certZtls_keyr'   kwargsZg0Zg1Zg2Zsecfr"   r9   ZsoftZhardlimitr$   r*   r   )r!   r)   r   main   st    m
0



rB   c                   C   s   t   t  d S r   )r   rB   r   r   r   r   go   s    rC   __main__)$r4   r+   loggingr   r.   r6   r,   ZclickZtornado.ioloopr   Zdistributedr   Zdistributed.cli.utilsr   r   Zdistributed.preloadingr   Zdistributed.proctitler   r   Z	getLoggerr<   PathZpem_file_option_typeZcommanddictoptionr2   intboolargumentZUNPROCESSEDZversion_optionrB   rC   __name__r   r   r   r   <module>   s   

2`
