def main(): # Parse arguments. try: parser = create_parser() except Exception as e: exit(f"Argument parsing exception : {e}") args = parser.parse_args(sys.argv[1:]) if args.config: conf_path = args.config if not IconConfig.valid_conf_path(conf_path): print(f'Invalid configuration file : {conf_path}') sys.exit(1) else: conf_path = str() # Load configuration conf = IconConfig(conf_path, tbears_server_config) conf.load() conf.update_conf(dict(vars(args))) Logger.load_config(conf) Logger.print_config(conf, TBEARS_BLOCK_MANAGER) setproctitle.setproctitle(f'{TBEARS_BLOCK_MANAGER}.{conf[TConfigKey.CHANNEL]}.{conf[TConfigKey.AMQP_KEY]}') # run block_manager service block_manager = BlockManager(conf=conf) block_manager.serve() Logger.info('===============tbears block_manager done================', TBEARS_BLOCK_MANAGER)
def main(): # Response server name as loopchain, not gunicorn. gunicorn.SERVER_SOFTWARE = 'loopchain' # Parse arguments. parser = argparse.ArgumentParser() parser.add_argument("-p", type=str, dest=ConfigKey.PORT, default=None, help="rest_proxy port") parser.add_argument("-c", type=str, dest=ConfigKey.CONFIG, default=None, help="json configure file path") args = parser.parse_args() conf_path = args.config if conf_path is not None: if not IconConfig.valid_conf_path(conf_path): print(f'invalid config file : {conf_path}') sys.exit(ExitCode.COMMAND_IS_WRONG.value) if conf_path is None: conf_path = str() conf = IconConfig(conf_path, default_rpcserver_config) conf.load() conf.update_conf(dict(vars(args))) Logger.load_config(conf) _run_async(_run(conf))
def main(): # Response server name as loopchain, not gunicorn. gunicorn.SERVER_SOFTWARE = 'loopchain' # Parse arguments. parser = argparse.ArgumentParser() parser.add_argument("-p", type=str, dest=ConfigKey.PORT, default=None, help="rest_proxy port") parser.add_argument("-c", type=str, dest=ConfigKey.CONFIG, default=None, help="json configure file path") parser.add_argument("-at", type=str, dest=ConfigKey.AMQP_TARGET, default=None, help="amqp target info [IP]:[PORT]") parser.add_argument( "-ak", type=str, dest=ConfigKey.AMQP_KEY, default=None, help= "key sharing peer group using queue name. use it if one more peers connect one MQ" ) parser.add_argument("-ch", dest=ConfigKey.CHANNEL, default=None, help="icon score channel") parser.add_argument("-tbears", dest=ConfigKey.TBEARS_MODE, action='store_true', help="tbears mode") args = parser.parse_args() conf_path = args.config if conf_path is not None: if not IconConfig.valid_conf_path(conf_path): print(f'invalid config file : {conf_path}') sys.exit(ExitCode.COMMAND_IS_WRONG.value) if conf_path is None: conf_path = str() conf = IconConfig(conf_path, default_rpcserver_config) conf.load() conf.update_conf(dict(vars(args))) Logger.load_config(conf) _run_async(_check_rabbitmq(conf[ConfigKey.AMQP_TARGET])) _run_async(_run(conf))
def main(): parser = argparse.ArgumentParser() parser.add_argument("-sc", dest=ConfigKey.SCORE_ROOT_PATH, type=str, default=None, help="icon score root path example : .score") parser.add_argument("-st", dest=ConfigKey.STATE_DB_ROOT_PATH, type=str, default=None, help="icon score state db root path example : .statedb") parser.add_argument("-ch", dest=ConfigKey.CHANNEL, type=str, default=None, help="icon score channel") parser.add_argument("-ak", dest=ConfigKey.AMQP_KEY, type=str, default=None, help="icon score amqp_key : [amqp_key]") parser.add_argument("-at", dest=ConfigKey.AMQP_TARGET, type=str, default=None, help="icon score amqp_target : [127.0.0.1]") parser.add_argument("-c", dest=ConfigKey.CONFIG, type=str, default=None, help="icon score config") parser.add_argument("-tbears", dest=ConfigKey.TBEARS_MODE, action='store_true', help="tbears mode") parser.add_argument("-steptrace", dest=ConfigKey.STEP_TRACE_FLAG, action="store_true", help="enable step tracing") args = parser.parse_args() args_params = dict(vars(args)) del args_params['config'] setproctitle.setproctitle(ICON_SERVICE_PROCTITLE_FORMAT.format(**args_params)) conf_path = args.config if conf_path is not None: if not IconConfig.valid_conf_path(conf_path): print(f'invalid config file : {conf_path}') sys.exit(ExitCode.INVALID_COMMAND.value) if conf_path is None: conf_path = str() conf = IconConfig(conf_path, copy.deepcopy(default_icon_config)) conf.load() conf.update_conf(args_to_dict(args)) Logger.load_config(conf) if not check_config(conf, default_icon_config): Logger.error(tag=_TAG, msg=f"Invalid Config") sys.exit(ExitCode.INVALID_CONFIG.value) Logger.print_config(conf, _TAG) _run_async(_check_rabbitmq(conf[ConfigKey.AMQP_TARGET])) icon_service = IconService() icon_service.serve(config=conf) Logger.info(f'==========IconService Done==========', _TAG)
def main(): parser = argparse.ArgumentParser(prog='iconrpcserver_cli.py', usage=f""" ========================== iconrpcserver server ========================== iconrpcserver commands: start : iconrpcserver start stop : iconrpcserver stop -p : rest_proxy port -c : json configure file path -at : amqp target info [IP]:[PORT] -ak : key sharing peer group using queue name. use it if one more peers connect one MQ -ch : loopchain channel ex) loopchain_default -fg : foreground process -tbears : tbears mode """) parser.add_argument('command', type=str, nargs='*', choices=['start', 'stop'], help='rest type [start|stop]') parser.add_argument("-p", type=str, dest=ConfigKey.PORT, default=None, help="rest_proxy port") parser.add_argument("-c", type=str, dest=ConfigKey.CONFIG, default=None, help="json configure file path") parser.add_argument("-at", type=str, dest=ConfigKey.AMQP_TARGET, default=None, help="amqp target info [IP]:[PORT]") parser.add_argument( "-ak", type=str, dest=ConfigKey.AMQP_KEY, default=None, help= "key sharing peer group using queue name. use it if one more peers connect one MQ" ) parser.add_argument("-ch", dest=ConfigKey.CHANNEL, default=None, help="icon score channel") parser.add_argument("-fg", dest='foreground', action='store_true', help="icon rpcserver run foreground") parser.add_argument("-tbears", dest=ConfigKey.TBEARS_MODE, action='store_true', help="tbears mode") args = parser.parse_args() if len(args.command) < 1: parser.print_help() sys.exit(ExitCode.COMMAND_IS_WRONG.value) conf_path = args.config if conf_path is not None: if not IconConfig.valid_conf_path(conf_path): print(f'invalid config file : {conf_path}') sys.exit(ExitCode.COMMAND_IS_WRONG.value) if conf_path is None: conf_path = str() conf = IconConfig(conf_path, default_rpcserver_config) conf.load() conf.update_conf(dict(vars(args))) Logger.load_config(conf) command = args.command[0] if command == 'start' and len(args.command) == 1: result = start(conf) elif command == 'stop' and len(args.command) == 1: result = stop(conf) else: parser.print_help() result = ExitCode.COMMAND_IS_WRONG.value sys.exit(result)
def main(): parser = argparse.ArgumentParser(prog='icon_service_cli.py', usage=f""" ========================== iconservice ========================== iconservice commands: start : iconservice start stop : iconservice stop -c : json configure file path -sc : icon score root path ex).score -st : icon score state db root path ex).state -at : amqp target info [IP]:[PORT] -ak : key sharing peer group using queue name. use it if one more peers connect one MQ -ch : loopchain channel ex) loopchain_default -fg : foreground process -tbears : tbears mode """) parser.add_argument('command', type=str, nargs='*', choices=['start', 'stop'], help='iconservice type [start|stop]') parser.add_argument("-sc", dest=ConfigKey.SCORE_ROOT_PATH, type=str, default=None, help="icon score root path example : .score") parser.add_argument("-st", dest=ConfigKey.STATE_DB_ROOT_PATH, type=str, default=None, help="icon score state db root path example : .statedb") parser.add_argument("-ch", dest=ConfigKey.CHANNEL, type=str, default=None, help="icon score channel") parser.add_argument("-ak", dest=ConfigKey.AMQP_KEY, type=str, default=None, help="icon score amqp_key : [amqp_key]") parser.add_argument("-at", dest=ConfigKey.AMQP_TARGET, type=str, default=None, help="icon score amqp_target : [127.0.0.1]") parser.add_argument("-c", dest=ConfigKey.CONFIG, type=str, default=None, help="icon score config") parser.add_argument("-fg", dest='foreground', action='store_true', help="icon score service run foreground") parser.add_argument("-tbears", dest=ConfigKey.TBEARS_MODE, action='store_true', help="tbears mode") args = parser.parse_args() if len(args.command) < 1: parser.print_help() sys.exit(ExitCode.COMMAND_IS_WRONG.value) conf_path = args.config if conf_path is not None: if not IconConfig.valid_conf_path(conf_path): print(f'invalid config file : {conf_path}') sys.exit(ExitCode.COMMAND_IS_WRONG.value) if conf_path is None: conf_path = str() conf = IconConfig(conf_path, default_icon_config) conf.load() conf.update_conf(dict(vars(args))) Logger.load_config(conf) command = args.command[0] if command == 'start' and len(args.command) == 1: result = _start(conf) elif command == 'stop' and len(args.command) == 1: result = _stop(conf) else: parser.print_help() result = ExitCode.COMMAND_IS_WRONG.value sys.exit(result)