Improve LND restart status

This commit is contained in:
Taylor Helsper 2021-04-30 23:39:58 -05:00
parent bbcedb2c0a
commit 384a4c8af2
4 changed files with 121 additions and 92 deletions

View File

@ -29,6 +29,7 @@ lightning_payments = None
lightning_invoices = None
lightning_watchtower_server_info = None
lightning_desync_count = 0
lightning_update_count = 0
LND_FOLDER = "/mnt/hdd/mynode/lnd/"
TLS_CERT_FILE = "/mnt/hdd/mynode/lnd/tls.cert"
@ -46,10 +47,17 @@ def update_lightning_info():
global lightning_invoices
global lightning_watchtower_server_info
global lightning_desync_count
global lightning_update_count
global lnd_ready
# Check logged in
#while not is_lnd_logged_in():
# lnd_ready = False
# time.sleep(10)
# Get latest LN info
lightning_info = lnd_get("/getinfo")
lightning_update_count = lightning_update_count + 1
# Set is LND ready
if lightning_info != None and "synced_to_chain" in lightning_info and lightning_info['synced_to_chain']:
@ -76,11 +84,12 @@ def update_lightning_info():
lightning_channels = lnd_get("/channels")
lightning_channel_balance = lnd_get("/balance/channels")
lightning_wallet_balance = lnd_get("/balance/blockchain")
#lightning_transactions = lnd_get("/transactions")
#lightning_payments = lnd_get("/payments")
#lightning_invoices = lnd_get("/invoices")
lightning_watchtower_server_info = lnd_get_v2("/watchtower/server")
# Poll slower
if lightning_update_count % 2 == 0:
update_lightning_tx_info()
return True
def update_lightning_tx_info():
@ -335,9 +344,11 @@ def restart_lnd_actual():
os.system("systemctl restart lnd_admin")
def restart_lnd():
t = Timer(1.0, restart_lnd_actual)
t = Timer(0.1, restart_lnd_actual)
t.start()
time.sleep(1)
def is_testnet_enabled():
return os.path.isfile("/mnt/hdd/mynode/settings/.testnet_enabled")

View File

@ -49,6 +49,7 @@ def page_lnd():
check_logged_in()
height = 0
refresh_rate = 3600
alias = get_lnd_alias_file_data()
num_peers = "0"
num_active_channels = "TODO"
@ -93,6 +94,7 @@ def page_lnd():
"version": get_lnd_version(),
"loop_version": get_loop_version(),
"pool_version": get_pool_version(),
"refresh_rate": 10,
"ui_settings": read_ui_settings()
}
return render_template('lnd.html', **templateData)
@ -152,10 +154,14 @@ def page_lnd():
"header": "Lightning Status",
#"message": str(e),
"message": traceback.format_exc(),
"refresh_rate": 10,
"ui_settings": read_ui_settings()
}
return render_template('error.html', **templateData)
if not is_lnd_ready():
refresh_rate = 15
templateData = {
"title": "myNode Lightning Status",
"wallet_exists": wallet_exists,
@ -189,6 +195,7 @@ def page_lnd():
"payments": payments,
"invoices": invoices,
"tx_display_limit": 8,
"refresh_rate": refresh_rate,
"ui_settings": read_ui_settings()
}
return render_template('lnd.html', **templateData)
@ -200,7 +207,7 @@ def lnd_regen_tls_cert():
os.system("rm /mnt/hdd/mynode/lnd/tls.cert")
os.system("rm /mnt/hdd/mynode/lnd/tls.key")
t = Timer(1.0, restart_lnd)
t = Timer(3.0, restart_lnd)
t.start()
flash("TLS Certificate Regenerated!", category="message")

View File

@ -2,6 +2,10 @@
<head>
<title>{{ title }}</title>
{% include 'includes/head.html' %}
{% if refresh_rate is defined and refresh_rate is not none %}
<meta http-equiv="refresh" content="{{ refresh_rate }}">
{% endif %}
</head>
<body>

View File

@ -3,6 +3,10 @@
<title>{{ title }}</title>
{% include 'includes/head.html' %}
{% if refresh_rate is defined and refresh_rate is not none %}
<meta http-equiv="refresh" content="{{ refresh_rate }}">
{% endif %}
<script>
$(document).ready(function() {
@ -311,7 +315,7 @@
</div>
{% endif %}
{% if watchtower_enabled %}
{% if wallet_logged_in and watchtower_enabled %}
<!-- URI Tile / Row -->
<div class="app_tile_row">
<div class="info_tile">
@ -375,98 +379,99 @@
</div>
</div>
<br/>
<div class="main_header">Recent Transactions</div>
<div class="app_tile_row">
{% if transactions and transactions|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">On-chain TX</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Confirmations</td>
</thead>
<tbody>
{% for tx in transactions[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.amount_str }}</td>
<td>{{ tx.num_confirmations }}</td>
</tr>
{% endfor %}
{% if transactions|length >= tx_display_limit %}
<td colspan=9>more...</td>
{% endif %}
</tbody>
</table>
{% endif %}
{% if payments and payments|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">Payments</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Fee</td>
<!--<td>Status</td>-->
</thead>
<tbody>
{% for tx in payments[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.value_str }}</td>
<td>{{ tx.fee_str }}</td>
<!--<td>{{ tx.status }}</td>-->
</tr>
{% endfor %}
{% if payments|length >= tx_display_limit %}
<td colspan=9>more...</td>
{% endif %}
</tbody>
</table>
{% endif %}
{% if invoices and invoices|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">Invoices</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Memo</td>
<td>State</td>
</thead>
<tbody>
{% for tx in invoices[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.value_str }}</td>
<td>
{% if tx.memo != "" %}
<img style="width: 16px;" src="{{ url_for('static', filename="images/memo.png")}}" title="{{ tx.memo }}"/>
{% endif %}
</td>
<td>{{ tx.state }}</td>
</tr>
{% if invoices|length >= tx_display_limit %}
{% if transactions and transactions|length > 0 or payments and payments|length > 0 or invoices and invoices|length > 0 %}
<br/>
<div class="main_header">Recent Transactions</div>
<div class="app_tile_row">
{% if transactions and transactions|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">On-chain</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Confirmations</td>
</thead>
<tbody>
{% for tx in transactions[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.amount_str }}</td>
<td>{{ tx.num_confirmations }}</td>
</tr>
{% endfor %}
{% if transactions|length >= tx_display_limit %}
<td colspan=9>more...</td>
{% endif %}
{% endfor %}
</tbody>
</table>
</tbody>
</table>
{% endif %}
{% if payments and payments|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">Payments</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Fee</td>
<!--<td>Status</td>-->
</thead>
<tbody>
{% for tx in payments[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.value_str }}</td>
<td>{{ tx.fee_str }}</td>
<!--<td>{{ tx.status }}</td>-->
</tr>
{% endfor %}
{% if payments|length >= tx_display_limit %}
<td colspan=9>more...</td>
{% endif %}
</tbody>
</table>
{% endif %}
{% if invoices and invoices|length > 0 %}
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
<thead class="bitcoin_table_header">
<td colspan=9 style="text-align: center;">Invoices</td>
</thead>
<thead class="bitcoin_table_header">
<td>Date</td>
<td>Amount</td>
<td>Memo</td>
<td>State</td>
</thead>
<tbody>
{% for tx in invoices[:tx_display_limit] %}
<tr>
<td>{{ tx.date_str }}</td>
<td>{{ tx.value_str }}</td>
<td>
{% if tx.memo != "" %}
<img style="width: 16px;" src="{{ url_for('static', filename="images/memo.png")}}" title="{{ tx.memo }}"/>
{% endif %}
</td>
<td>{{ tx.state }}</td>
</tr>
{% if invoices|length >= tx_display_limit %}
<td colspan=9>more...</td>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
{% endif %}
</div>
{% if channels and channels|length > 0 %}
<br/>
<div class="main_header">Channels</div>
{% if channels|length > 0 %}
<div class="app_tile_row">
<div class="lightning_channel_container" style="width: 1000px;">
{% for c in channels %}
@ -510,6 +515,7 @@
</div>
{% endif %}
{% if peers and peers|length > 0 %}
<br/>
<div class="main_header">Peers</div>
<div class="app_tile_row">
@ -536,6 +542,7 @@
</tbody>
</table>
</div>
{% endif %}
{% endif %}
{% if wallet_exists and wallet_logged_in %}