main: Catch for offline worker
This commit is contained in:
parent
ba96f9b84b
commit
7703bfa4d5
@ -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>"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user