Update backend readiness check to use TCP port instead of Unix socket

parent 12720b46
...@@ -379,22 +379,13 @@ Examples: ...@@ -379,22 +379,13 @@ Examples:
max_wait = 15 max_wait = 15
for i in range(max_wait): for i in range(max_wait):
try: try:
if is_unix_sockets_supported(): # Check TCP port for worker
# Check Unix socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.settimeout(1)
sock.settimeout(1) sock.connect((args.backend_host, args.backend_worker_port))
sock.connect(get_socket_path('worker')) sock.close()
sock.close() print("Backend TCP port is ready!")
print("Backend Unix socket is ready!") break
break
else:
# Check TCP port
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
sock.connect((args.backend_host, args.backend_worker_port))
sock.close()
print("Backend TCP port is ready!")
break
except (FileNotFoundError, ConnectionRefusedError, OSError): except (FileNotFoundError, ConnectionRefusedError, OSError):
if i < max_wait - 1: if i < max_wait - 1:
print(f"Waiting for backend... ({i+1}/{max_wait})") print(f"Waiting for backend... ({i+1}/{max_wait})")
...@@ -430,22 +421,13 @@ Examples: ...@@ -430,22 +421,13 @@ Examples:
max_wait = 15 max_wait = 15
for i in range(max_wait): for i in range(max_wait):
try: try:
if is_unix_sockets_supported(): # Check TCP port for worker
# Check Unix socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.settimeout(1)
sock.settimeout(1) sock.connect((args.backend_host, args.backend_worker_port))
sock.connect(get_socket_path('worker')) sock.close()
sock.close() print("Backend TCP port is ready!")
print("Backend Unix socket is ready!") break
break
else:
# Check TCP port
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
sock.connect((args.backend_host, args.backend_worker_port))
sock.close()
print("Backend TCP port is ready!")
break
except (FileNotFoundError, ConnectionRefusedError, OSError): except (FileNotFoundError, ConnectionRefusedError, OSError):
if i < max_wait - 1: if i < max_wait - 1:
print(f"Waiting for backend... ({i+1}/{max_wait})") print(f"Waiting for backend... ({i+1}/{max_wait})")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment