Add tracker status to Dojo page

This commit is contained in:
Taylor Helsper 2020-04-11 16:16:50 -05:00
parent 1cc87c0124
commit de26c3864a
2 changed files with 32 additions and 0 deletions

View File

@ -3,7 +3,9 @@ from flask import Blueprint, render_template, redirect
from settings import read_ui_settings
from user_management import check_logged_in
from enable_disable_functions import is_dojo_enabled, enable_dojo, disable_dojo
from bitcoin_info import get_mynode_block_height
import subprocess
import re
import os
mynode_dojo = Blueprint('mynode_dojo',__name__)
@ -28,6 +30,31 @@ def get_dojo_status():
dojo_initialized = ""
return dojo_status, dojo_status_color, dojo_initialized
def get_dojo_tracker_status():
try:
tracker_log = subprocess.check_output("docker exec nodejs tail -n 50 /data/logs/tracker-output.log", shell=True)
except:
return "error"
lines = tracker_log.splitlines()
lines.reverse()
tracker_status = "unknown"
for line in lines:
if "Added block header" in line:
m = re.search("block header ([0-9]+)", line)
dojo_height = m.group(1)
bitcoin_height = get_mynode_block_height()
tracker_status = "Syncing... {} of {}".format(dojo_height, bitcoin_height)
break
elif "Processing active Mempool" in line:
tracker_status = "Active"
break
return tracker_status
### Page functions
@mynode_dojo.route("/dojo")
def dojo_page():
@ -58,6 +85,7 @@ def dojo_page():
"dojo_status_color": dojo_status_color,
"dojo_enabled": is_dojo_enabled(),
"dojo_initialized": dojo_initialized,
"dojo_tracker_status": get_dojo_tracker_status(),
"NODE_ADMIN_KEY": NODE_ADMIN_KEY,
"DOJO_V3_ADDR": DOJO_V3_ADDR
}

View File

@ -17,6 +17,10 @@
<div class="info_tile_contents">{{dojo_status}}</div>
</div>
{% if dojo_enabled %}
<div class="info_tile">
<div class="info_tile_header">Tracker Status</div>
<div class="info_tile_contents">{{dojo_tracker_status}}</div>
</div>
<div class="info_tile">
<div class="info_tile_header">Restart</div>
<div class="info_tile_contents">