Add running container info to status page

This commit is contained in:
Taylor Helsper 2020-05-11 20:31:49 -05:00
parent c2d218d19b
commit 7ddb30b2fd
4 changed files with 42 additions and 0 deletions

View File

@ -446,6 +446,15 @@ def reset_docker():
os.system("sync")
reboot_device()
def get_docker_running_containers():
containers = []
try:
text = subprocess.check_output("docker ps --format '{{.Names}}'", shell=True).decode("utf8")
containers = text.splitlines()
except:
containers = ["ERROR"]
return containers
#==================================
# Bitcoin Functions
#==================================

View File

@ -217,6 +217,18 @@ def page_status():
docker_status_log = get_journalctl_log("docker")
docker_image_build_status_log = get_journalctl_log("docker_images")
# Find running containers
running_containers = get_docker_running_containers()
webssh_cont_running = "webssh" in running_containers
mempool_cont_running = "mempoolspace" in running_containers
dojo_tor_cont_running = "tor" in running_containers
dojo_nodejs_cont_running = "nodejs" in running_containers
dojo_nginx_cont_running = "nginx" in running_containers
dojo_db_cont_running = "db" in running_containers
btcpay_btcpay_cont_running = "btcpayserver_btcpayserver_1" in running_containers
btcpay_nbxplorer_tor_cont_running = "btcpayserver_nbxplorer_1" in running_containers
btcpay_postgres_tor_cont_running = "btcpayserver_postgres_1" in running_containers
templateData = {
"title": "myNode Status",
"password_message": "",
@ -233,6 +245,7 @@ def page_status():
"product_key_skipped": pk_skipped,
"product_key_error": pk_error,
"changelog": changelog,
"running_containers": running_containers,
"startup_status_log": startup_status_log,
"startup_status": get_service_status_basic_text("mynode"),
"startup_status_color": get_service_status_color("mynode"),

View File

@ -374,6 +374,9 @@ a:active {
font-size: 14px;
font-family: Arial, Helvetica, sans-serif;
}
.status_container_list {
margin-left: 150px;
}
.seed_textbox {
width: 99%;

View File

@ -333,6 +333,13 @@
<div class="settings_block_subheader_status">
<div class="settings_block_subheader_status_icon {{ dojo_status_color }}"></div>
{{ dojo_status }}
<span class='status_container_list'>
Running Containers:
{% if 'tor' in running_containers %} tor {% endif %}
{% if 'nodejs' in running_containers %} nodejs {% endif %}
{% if 'db' in running_containers %} db {% endif %}
{% if 'nginx' in running_containers %} nginx {% endif %}
</span>
</div>
<button id="show_dojo_status" class="ui-button ui-widget ui-corner-all settings_button_small">Show Log</button>
<div id="dojo_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{dojo_status_log}}</pre></div>
@ -342,6 +349,12 @@
<div class="settings_block_subheader_status">
<div class="settings_block_subheader_status_icon {{ btcpayserver_status_color }}"></div>
{{ btcpayserver_status }}
<span class='status_container_list'>
Running Containers:
{% if 'btcpayserver_btcpayserver_1' in running_containers %} btcpayserver {% endif %}
{% if 'btcpayserver_nbxplorer_1' in running_containers %} nbxplorer {% endif %}
{% if 'btcpayserver_postgres_1' in running_containers %} postgres {% endif %}
</span>
</div>
<button id="show_btcpayserver_status" class="ui-button ui-widget ui-corner-all settings_button_small">Show Log</button>
<div id="btcpayserver_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{btcpayserver_status_log}}</pre></div>
@ -351,6 +364,10 @@
<div class="settings_block_subheader_status">
<div class="settings_block_subheader_status_icon {{ mempoolspace_status_color }}"></div>
{{ mempoolspace_status }}
<span class='status_container_list'>
Running Containers:
{% if 'mempoolspace' in running_containers %} mempoolspace {% endif %}
</span>
</div>
<button id="show_mempoolspace_status" class="ui-button ui-widget ui-corner-all settings_button_small">Show Log</button>
<div id="mempoolspace_status" style='text-align: left; font-size: 12px; width: 800px; display: none;'><pre>{{mempoolspace_status_log}}</pre></div>