main: Catch for offline worker
This commit is contained in:
parent
ba96f9b84b
commit
7703bfa4d5
@ -182,17 +182,22 @@ def list_workers():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
online=True
|
online=True
|
||||||
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
|
try:
|
||||||
if (resp.status_code != 200):
|
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
|
||||||
online=False
|
|
||||||
worker_list.append({'worker': worker.split(':')[0],'ip': worker.split(':')[2].strip('\n'), 'online': online, 'sites': 0, 'status': 'offline'})
|
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'})
|
||||||
|
continue
|
||||||
|
sites = resp.json()['num_sites']
|
||||||
|
availability = resp.json()['availability']
|
||||||
|
if availability == True:
|
||||||
|
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
|
continue
|
||||||
sites = resp.json()['num_sites']
|
|
||||||
availability = resp.json()['availability']
|
|
||||||
if availability == True:
|
|
||||||
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'})
|
|
||||||
|
|
||||||
if len(worker_list) == 0:
|
if len(worker_list) == 0:
|
||||||
return jsonify({'error': 'No workers available', 'success': 'false'})
|
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]
|
html += "<p>Name: " + worker.split(':')[0] + " | Public IP " + worker.split(':')[2].strip('\n') + " | Private IP " + worker.split(':')[1]
|
||||||
# Check worker status
|
# Check worker status
|
||||||
online=True
|
online=True
|
||||||
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
|
try:
|
||||||
if (resp.status_code != 200):
|
resp=requests.get("http://"+worker.split(':')[1].strip('\n') + ":5000/status",timeout=2)
|
||||||
online=False
|
if (resp.status_code != 200):
|
||||||
if online:
|
html += " | Status: Offline"
|
||||||
html += " | Status: Online | Sites: " + str(resp.json()['num_sites']) + " | Availability: " + str(resp.json()['availability'])
|
else:
|
||||||
else:
|
html += " | Status: Online | Sites: " + str(resp.json()['num_sites']) + " | Availability: " + str(resp.json()['availability'])
|
||||||
|
except:
|
||||||
html += " | Status: Offline"
|
html += " | Status: Offline"
|
||||||
|
|
||||||
html += "</p>"
|
html += "</p>"
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user