Fix node hostname switcharoo on Mac

pull/1279/head
Piero Toffanin 2022-12-14 01:19:36 -05:00
rodzic d87c500921
commit ad41692aa3
1 zmienionych plików z 17 dodań i 0 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ import shutil
import tempfile
import traceback
import json
import socket
import time
from threading import Event, Thread
@ -35,6 +36,22 @@ def update_nodes_info():
for processing_node in processing_nodes:
processing_node.update_node_info()
# Workaround for mysterious "webodm_node-odm-1" or "webodm-node-odm-1" hostname switcharoo on Mac
# Technically we already check for the correct hostname during setup,
# but sometimes that doesn't work?
check_hostname = 'webodm_node-odm-1'
if processing_node.hostname == check_hostname and not processing_node.is_online():
try:
socket.gethostbyname(processing_node.hostname)
except:
# Hostname was invalid, try renaming
processing_node.hostname = 'webodm-node-odm-1'
processing_node.update_node_info()
if processing_node.is_online():
logger.info("Found and fixed webodm_node-odm-1 hostname switcharoo")
else:
processing_node.hostname = check_hostname
processing_node.save()
@app.task
def cleanup_projects():