mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-12-27 06:54:00 +00:00
Start BTC RPC Explorer after Electrs
This commit is contained in:
parent
bdf54d088f
commit
97a770ab26
|
@ -8,6 +8,7 @@ After=bitcoind.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
|
ExecStartPre=/usr/bin/wait_on_bitcoin.sh
|
||||||
|
ExecStartPre=/usr/bin/wait_on_electrs.sh
|
||||||
WorkingDirectory=/opt/mynode/btc-rpc-explorer
|
WorkingDirectory=/opt/mynode/btc-rpc-explorer
|
||||||
ExecStart=/usr/bin/npm start
|
ExecStart=/usr/bin/npm start
|
||||||
|
|
||||||
|
|
13
rootfs/standard/usr/bin/wait_on_electrs.sh
Executable file
13
rootfs/standard/usr/bin/wait_on_electrs.sh
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Wait to see if bitcoind is synced
|
||||||
|
echo "Checking if electrum server is ready is synced..."
|
||||||
|
while [ ! -f "/tmp/electrs_up_to_date" ]; do
|
||||||
|
echo "electrs not synced, sleeping 1m"
|
||||||
|
/bin/sleep 30s
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
|
@ -4,6 +4,7 @@ import subprocess
|
||||||
import requests
|
import requests
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
electrum_server_current_block = None
|
electrum_server_current_block = None
|
||||||
|
@ -15,6 +16,7 @@ def get_electrum_server_current_block():
|
||||||
|
|
||||||
def update_electrs_info():
|
def update_electrs_info():
|
||||||
global electrum_server_current_block
|
global electrum_server_current_block
|
||||||
|
global electrs_active
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raw_data = requests.get("http://localhost:4224")
|
raw_data = requests.get("http://localhost:4224")
|
||||||
|
@ -23,6 +25,12 @@ def update_electrs_info():
|
||||||
for sample in family.samples:
|
for sample in family.samples:
|
||||||
if sample.name == "electrs_index_height":
|
if sample.name == "electrs_index_height":
|
||||||
electrum_server_current_block = int(sample.value)
|
electrum_server_current_block = int(sample.value)
|
||||||
|
|
||||||
|
bitcoin_block_height = get_bitcoin_block_height()
|
||||||
|
if electrum_server_current_block != None and bitcoin_block_height != None:
|
||||||
|
if electrum_server_current_block > bitcoin_block_height - 2:
|
||||||
|
os.system("touch /tmp/electrs_up_to_date")
|
||||||
|
electrs_active = True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -299,11 +299,16 @@ def index():
|
||||||
# Find btc-rpc-explorer status
|
# Find btc-rpc-explorer status
|
||||||
btcrpcexplorer_status = "BTC RPC Explorer"
|
btcrpcexplorer_status = "BTC RPC Explorer"
|
||||||
if is_btcrpcexplorer_enabled():
|
if is_btcrpcexplorer_enabled():
|
||||||
|
if is_electrs_active():
|
||||||
status = os.system("systemctl status btc_rpc_explorer --no-pager")
|
status = os.system("systemctl status btc_rpc_explorer --no-pager")
|
||||||
if status != 0:
|
if status != 0:
|
||||||
btcrpcexplorer_status_color = "red"
|
btcrpcexplorer_status_color = "red"
|
||||||
else:
|
else:
|
||||||
btcrpcexplorer_status_color = "green"
|
btcrpcexplorer_status_color = "green"
|
||||||
|
btcrpcexplorer_ready = True
|
||||||
|
else:
|
||||||
|
btcrpcexplorer_status_color = "green"
|
||||||
|
btcrpcexplorer_status = "Waiting on electrs..."
|
||||||
|
|
||||||
# Find explorer status
|
# Find explorer status
|
||||||
explorer_status_color = electrs_status_color
|
explorer_status_color = electrs_status_color
|
||||||
|
|
|
@ -59,9 +59,13 @@
|
||||||
<div class="app_status">{{ btcrpcexplorer_status }}</div>
|
<div class="app_status">{{ btcrpcexplorer_status }}</div>
|
||||||
<div class="app_contents">
|
<div class="app_contents">
|
||||||
{% if btcrpcexplorer_enabled %}
|
{% if btcrpcexplorer_enabled %}
|
||||||
|
{% if btcrpcexplorer_ready %}
|
||||||
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="btcrpcexplorer">Explorer</a>
|
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="btcrpcexplorer">Explorer</a>
|
||||||
|
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-btcrpcexplorer">Disable</a>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-btcrpcexplorer">Enable</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a class="ui-button ui-widget ui-corner-all mynode_button" href="#" id="toggle-btcrpcexplorer">{% if btcrpcexplorer_enabled %}Disable{% else %}Enable{% endif %}</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="app_tile">
|
<div class="app_tile">
|
||||||
|
|
Loading…
Reference in New Issue
Block a user