示例#1
0
def start_process(conf: 'IconConfig'):
    Logger.debug('start_server() start')
    python_module_string = 'iconrpcserver.icon_rpcserver_app'

    converted_params = {
        '-p': conf[ConfigKey.PORT],
        '-c': conf.get(ConfigKey.CONFIG),
        '-at': conf[ConfigKey.AMQP_TARGET],
        '-ak': conf[ConfigKey.AMQP_KEY],
        '-ch': conf[ConfigKey.CHANNEL]
    }

    custom_argv = []
    for k, v in converted_params.items():
        if v is None:
            continue
        custom_argv.append(k)
        custom_argv.append(str(v))
    if conf[ConfigKey.TBEARS_MODE]:
        custom_argv.append('-tbears')

    is_foreground = conf.get('foreground', False)
    if is_foreground:
        from iconrpcserver.icon_rpcserver_app import run_in_foreground
        del conf['foreground']
        run_in_foreground(conf)
    else:
        subprocess.Popen(
            [sys.executable, '-m', python_module_string, *custom_argv],
            close_fds=True)
    Logger.debug('start_process() end')
示例#2
0
def start_as_rest_server(args):
    from iconcommons.icon_config import IconConfig
    from iconcommons.logger import Logger
    from iconrpcserver.default_conf.icon_rpcserver_config import default_rpcserver_config
    from iconrpcserver import icon_rpcserver_app

    amqp_key = args.amqp_key or conf.AMQP_KEY
    api_port = int(args.port) + conf.PORT_DIFF_REST_SERVICE_CONTAINER
    conf_path = conf.CONF_PATH_ICONRPCSERVER_DEV

    if args.radio_station_target == conf.URL_CITIZEN_TESTNET:
        conf_path = conf.CONF_PATH_ICONRPCSERVER_TESTNET
    elif args.radio_station_target == conf.URL_CITIZEN_MAINNET:
        conf_path = conf.CONF_PATH_ICONRPCSERVER_MAINNET

    additional_conf = {
        "port": api_port,
        "amqpTarget": conf.AMQP_TARGET,
        "amqpKey": amqp_key,
        "channel": conf.LOOPCHAIN_DEFAULT_CHANNEL
    }

    rpcserver_conf: IconConfig = IconConfig(conf_path,
                                            default_rpcserver_config)
    rpcserver_conf.load()
    rpcserver_conf.update_conf(additional_conf)
    Logger.load_config(rpcserver_conf)

    icon_rpcserver_app.run_in_foreground(rpcserver_conf)