<s> import functools <EOL> from app . slave . cluster_slave import ClusterSlave <EOL> from app . subcommands . service_subcommand import ServiceSubcommand <EOL> from app . util import analytics , log <EOL> from app . util . conf . configuration import Configuration <EOL> from app . web_framework . cluster_slave_application import ClusterSlaveApplication <EOL> class SlaveSubcommand ( ServiceSubcommand ) : <EOL> _THREAD_NAME = '<STR_LIT>' <EOL> def async_run ( self , port , master_url , num_executors , log_level , eventlog_file ) : <EOL> """<STR_LIT>""" <EOL> num_executors = num_executors or Configuration [ '<STR_LIT>' ] <EOL> master_url = master_url or '<STR_LIT>' . format ( Configuration [ '<STR_LIT>' ] , Configuration [ '<STR_LIT>' ] ) <EOL> port = port or Configuration [ '<STR_LIT:port>' ] <EOL> log_level = log_level or Configuration [ '<STR_LIT>' ] <EOL> eventlog_file = eventlog_file or Configuration [ '<STR_LIT>' ] <EOL> log . configure_logging ( log_level = log_level , log_file = Configuration [ '<STR_LIT>' ] . format ( port ) ) <EOL> analytics . initialize ( eventlog_file ) <EOL> analytics . record_event ( analytics . SERVICE_STARTED , service = '<STR_LIT>' ) <EOL> cluster_slave = ClusterSlave ( <EOL> port = port , <EOL> num_executors = num_executors , <EOL> host = Configuration [ '<STR_LIT>' ] , <EOL> ) <EOL> application = ClusterSlaveApplication ( cluster_slave ) <EOL> ioloop = self . _start_application ( application , port ) <EOL> self . _write_pid_file ( Configuration [ '<STR_LIT>' ] ) <EOL> connect_slave_to_master = functools . partial ( cluster_slave . connect_to_master , master_url = master_url ) <EOL> ioloop . add_callback ( connect_slave_to_master ) <EOL> ioloop . start ( ) <EOL> ioloop . close ( all_fds = True ) <EOL> self . _logger . notice ( '<STR_LIT>' ) </s>
