main: Catch for offline worker
All checks were successful
Build Docker / Build Bot (push) Successful in 22s
Build Docker / Build Master (push) Successful in 28s

This commit is contained in:
Nathan Woodburn 2023-08-25 17:31:32 +10:00
parent ba96f9b84b
commit 7703bfa4d5
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -182,7 +182,9 @@ def list_workers():
continue
online=True
try:
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
if (resp.status_code != 200):
online=False
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[2].strip('\n'), 'online': online, 'sites': 0, 'status': 'offline'})
@ -193,6 +195,9 @@ def list_workers():
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[2].strip('\n'), 'online': online, 'sites': sites, 'status': 'ready'})
else:
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[2].strip('\n'), 'online': online, 'sites': sites, 'status': 'full'})
except:
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[2].strip('\n'), 'online': 'False', 'sites': 0, 'status': 'offline'})
continue
if len(worker_list) == 0:
return jsonify({'error': 'No workers available', 'success': 'false'})
@ -501,13 +506,15 @@ def admin():
html += "<p>Name: " + worker.split(':')[0] + " | Public IP " + worker.split(':')[2].strip('\n') + " | Private IP " + worker.split(':')[1]
# Check worker status
online=True
try:
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"
else:
html += " | Status: Online | Sites: " + str(resp.json()['num_sites']) + " | Availability: " + str(resp.json()['availability'])
except:
html += " | Status: Offline"
html += "</p>"