mirror of
https://github.com/blw1138/Zordon.git
synced 2025-12-17 16:58:12 +00:00
Additional work to allow registering of remote clients
This commit is contained in:
@@ -284,12 +284,12 @@ class RenderServer:
|
||||
return success
|
||||
|
||||
try:
|
||||
response = requests.get(f"https://{hostname}/status", timeout=1)
|
||||
response = requests.get(f"http://{hostname}:8080/status", timeout=1)
|
||||
if response.ok:
|
||||
cls.render_clients.append(hostname)
|
||||
logger.info(f"Client '{hostname}' successfully registered")
|
||||
success = True
|
||||
except requests.exceptions.ConnectTimeout as e:
|
||||
except requests.ConnectionError as e:
|
||||
logger.error(f"Cannot connect to client at hostname: {hostname}")
|
||||
return success
|
||||
|
||||
@@ -336,11 +336,11 @@ class RenderServer:
|
||||
|
||||
if background_thread:
|
||||
server_thread = threading.Thread(
|
||||
target=lambda: app.run(host=cls.host_name, port=cls.port, debug=False, use_reloader=False))
|
||||
target=lambda: app.run(host='0.0.0.0', port=cls.port, debug=False, use_reloader=False))
|
||||
server_thread.start()
|
||||
server_thread.join()
|
||||
else:
|
||||
app.run(host=cls.host_name, port=cls.port, debug=config.get('flask_debug_enable', False),
|
||||
app.run(host='0.0.0.0', port=cls.port, debug=config.get('flask_debug_enable', False),
|
||||
use_reloader=False)
|
||||
|
||||
|
||||
@@ -378,11 +378,20 @@ def full_status():
|
||||
|
||||
try:
|
||||
for client_hostname in RenderServer.render_clients:
|
||||
is_online = False
|
||||
if client_hostname == local_hostname:
|
||||
snapshot_results = snapshot()
|
||||
is_online = True
|
||||
else:
|
||||
snapshot_results = requests.get(f'http://{client_hostname}:8080/snapshot', timeout=1).json()
|
||||
server_data = {'status': snapshot_results.get('status'), 'jobs': snapshot_results.get('jobs')}
|
||||
snapshot_results = {}
|
||||
try:
|
||||
snapshot_request = requests.get(f'http://{client_hostname}:8080/snapshot', timeout=1)
|
||||
snapshot_results = snapshot_request.json()
|
||||
is_online = snapshot_request.ok
|
||||
except requests.ConnectionError as e:
|
||||
pass
|
||||
server_data = {'status': snapshot_results.get('status', {}), 'jobs': snapshot_results.get('jobs', {}),
|
||||
'is_online': is_online}
|
||||
full_results['servers'][client_hostname] = server_data
|
||||
except Exception as e:
|
||||
logger.error(f"Exception fetching full status: {e}")
|
||||
@@ -505,4 +514,5 @@ def upload_file():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
start_server()
|
||||
RenderServer.start()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user