Example #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("command",
                        help="sub command: drop, build, work, miner")
    parser.add_argument("--conf", help="conf file", default="debug.conf")
    parser.add_argument("params", nargs=argparse.REMAINDER)

    args = parser.parse_args()

    args.conf = os.path.abspath(args.conf)
    print(f"config file: {args.conf}")
    config = utils.merge_config(args.conf)
    print(f"database: {config.database['uri']}")
    connect_to_db(config)

    if args.command == "drop":
        drop_col(args.params, force=False)
    elif args.command == "build":
        build_debug_db(args.params)
    elif args.command == "work":
        build_pow_work(args.params)
    elif args.command == "miner":
        show_miners(args.params)
    elif args.command == "keys":
        keypairs(args.params)
    else:
        parser.print_help()
Example #2
0
async def start_servers(conf_file=None, host=None, port=None):
    from zilpool.common import utils, mail, blockchain
    from zilpool.database import init_db, connect_to_db

    # merge user's config with default.conf
    config = utils.merge_config(conf_file)

    # setup logfile
    setup_logging(config["logging"])

    # init tools
    mail.EmailClient.set_config(config)

    # init database
    connect_to_db(config)
    init_db(config)

    # init Zilliqa network APIs
    blockchain.Zilliqa.init(config)

    # init app
    app = web.Application(debug=config["debug"])
    init_apis(app, config)
    init_website(app, config)

    # start background tasks
    app["config"] = config
    app.on_startup.append(backgound.start_background_tasks)
    app.on_cleanup.append(backgound.cleanup_background_tasks)

    # start the server
    if port is None:
        port = config["api_server"].get("port", "4202")
    if host is None:
        host = config["api_server"].get("host", "0.0.0.0")

    runner = web.AppRunner(app)
    loop = asyncio.get_event_loop()

    await runner.setup()
    #loop.run_until_complete(runner.setup())
    site = web.TCPSite(runner, host=host, port=port)
    #loop.run_until_complete(site.start())
    await (site.start())

    # update config
    update_config(site, config)

    # start stratum server
    await start_stratum(config)
Example #3
0
def start_servers(conf_file=None, host=None, port=None):
    from zilpool.common import utils, mail
    from zilpool.database import init_db, connect_to_db

    # merge user's config with default.conf
    config = utils.merge_config(conf_file)

    # setup logfile
    setup_logging(config["logging"])

    # init tools
    mail.EmailClient.set_config(config)

    # init database
    connect_to_db(config)
    init_db(config)

    # init app
    app = web.Application(debug=config["debug"])
    init_apis(app, config)
    init_website(app, config)

    # start the server
    if port is None:
        port = config["api_server"].get("port", "4202")
    if host is None:
        host = config["api_server"].get("host", "0.0.0.0")

    runner = web.AppRunner(app)
    loop = asyncio.get_event_loop()
    loop.run_until_complete(runner.setup())
    site = web.TCPSite(runner, host=host, port=port)
    loop.run_until_complete(site.start())

    # update config
    update_config(site, config)

    # start ioloop
    loop.run_forever()
def get_config(conf):
    conf_file = os.path.join(cur_dir, conf)
    return merge_config(conf_file)