This is an automated email from the ASF dual-hosted git repository. dimuthuupe pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/airavata-mft.git
commit 419b55a761484549a2501c02da6291599b50f98a Author: Shivang Mishra <[email protected]> AuthorDate: Mon Apr 1 11:23:38 2024 +0530 wait for consul before starting mft --- python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py index a2d9085..5102ba4 100644 --- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py +++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py @@ -27,6 +27,7 @@ from subprocess import Popen from pathlib import Path from sys import platform import shutil +import socket import time def download_and_unarchive(url, download_path, extract_dir = os.path.join(os.path.expanduser('~'), ".mft/")): @@ -105,6 +106,9 @@ def validate_java_availability(required_version): print("Java is either not installed or path hasn't been set properly") raise typer.Exit() +def is_port_open(port): + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + return s.connect_ex(('localhost', port)) == 0 def start_mft(): print("Setting up MFT Services") @@ -160,6 +164,10 @@ def start_mft(): zip_path = os.path.join(os.path.expanduser('~'), ".mft/Standalone-Service-0.01-bin.zip") download_and_unarchive(url, zip_path) + while not is_port_open(8500): + print("Waiting for Consul to start...") + time.sleep(1) + restart_service(path + "/bin", "standalone-service-daemon.sh") print("MFT Started")
