def get_electrs_status():
    global electrum_server_current_block
    global electrs_active

    if not is_electrs_enabled():
        return "Disabled"

    bitcoin_block_height = get_bitcoin_block_height()
    log = ""
    try:
        log += subprocess.check_output(
            "journalctl --unit=electrs --no-pager | tail -n 100", shell=True)
    except:
        log += ""
    lines = log.splitlines()
    lines.reverse()
    for line in lines:
        if "left to index)" in line:
            break
        elif "Checking if Bitcoin is synced..." in line or "NetworkInfo {" in line or "BlockchainInfo {" in line:
            return "Starting..."
        elif "opening DB at" in line or "enabling auto-compactions" in line:
            return "Starting..."
        elif "downloading 100000 block headers" in line:
            return "Getting headers..."
        elif "starting full compaction" in line:
            return "Compressing..."
        elif "enabling auto-compactions" in line:
            break
        elif "RPC server running on" in line:
            break

    if electrum_server_current_block != None and bitcoin_block_height != None:
        if electrum_server_current_block < bitcoin_block_height - 10:
            percent = 100.0 * (float(electrum_server_current_block) /
                               bitcoin_block_height)
            return "Syncing... {:.2f}%".format(abs(percent))
        else:
            electrs_active = True
            return "Running"
    return ""
def is_electrs_active():
    global electrs_active
    if not is_electrs_enabled():
        return False
    return electrs_active