main: Fixed worker info
All checks were successful
Build Docker / Build Bot (push) Successful in 26s
Build Docker / Build Master (push) Successful in 27s

This commit is contained in:
Nathan Woodburn 2023-08-25 17:13:34 +10:00
parent c9be5cedcb
commit 0a33a6150d
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -486,8 +486,27 @@ def admin():
html += "<p>Stripe is enabled</p>"
html += "<br><br><h2>Workers</h2>"
for worker in list_workers().json()['workers']:
html += "<p>Worker: " + worker['worker'] + " | IP: " + worker['ip'] + " | Status: " + worker['status'] + " | Sites: " + str(worker['sites']) + "</p>"
workers = []
try:
workers_file = open('/data/workers.txt', 'r')
workers = workers_file.readlines()
workers_file.close()
except FileNotFoundError:
pass
for worker in workers:
html += "<p>Name: " + worker.split(':')[0] + " | Public IP " + worker.split(':')[2].strip('\n') + " | Private IP " + worker.split(':')[1]
# Check worker status
online=True
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
if (resp.status_code != 200):
online=False
if online:
html += " | Status: Online | Sites: " + str(resp.json()['num_sites']) + " | Availability: " + str(resp.json()['availability'])
else:
html += " | Status: Offline"
html += "</p>"
html += "<h2>Sites</h2>"
sites = []