Example #1
0
def setup(node_yml=None):
    if node_yml:
        conf.NODE_YML = abspath(node_yml)
    auto = AutoDeployPlaton(is_metrics=True)
    # auto.check_node_yml(conf.NODE_YML)
    # auto.booms(conf.NODE_YML)
    # auto.deploy_default_yml(conf.NODE_YML)
    auto.kill_of_yaml(conf.NODE_YML)
Example #2
0
def monitor(node_yml):
    auto = AutoDeployPlaton()
    collusion, nocollusion = get_node_list(node_yml)
    node_list = collusion + nocollusion
    old_block = [0 * i for i in range(len(collusion))]
    t = 0
    while True:
        time.sleep(120)
        t += 120
        block_list = []
        url_list = []
        for node in node_list:
            try:
                w3 = connect_web3(node["url"])
                if not w3.isConnected():
                    raise Exception("有节点被关闭了")
                block = w3.eth.blockNumber
                block_list.append(block)
                url_list.append(node["url"])

            except:
                close_msg = "节点:{}:{}无法连接\n".format(node["host"], node["port"])
                log.warning(close_msg)
        msg = build_msg(url_list, block_list, old_block)
        if max(block_list) - min(block_list) >= 100:
            log.error("区块差距过大")
            auto.kill_of_yaml(node_yml)
            send_to_gap(block_list, msg, node_yml)
        if max(block_list) - min(old_block) == 0:
            log.error("不出块了")
            auto.kill_of_yaml(node_yml)
            send_to_block(msg, node_yml)
        if t >= 21600:
            t = 0
            send_email(EmailInfo, msg)
        old_block = block_list
Example #3
0
def teardown():
    auto = AutoDeployPlaton()
    auto.kill_of_yaml(conf.NODE_YML)