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 3ccbfa2a5bc30e50bb385297ce82e809331967bf Author: Shivang Mishra <[email protected]> AuthorDate: Wed Apr 3 14:03:42 2024 +0530 feat(bootstrap): when start mft, quit if consul does not start after 20 second wait --- python-cli/mft_cli/airavata_mft_cli/bootstrap.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py index 5102ba4..d130711 100644 --- a/python-cli/mft_cli/airavata_mft_cli/bootstrap.py +++ b/python-cli/mft_cli/airavata_mft_cli/bootstrap.py @@ -106,10 +106,10 @@ 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): +def is_consul_running(): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: - return s.connect_ex(('localhost', port)) == 0 - + return s.connect_ex(('localhost', 8500)) == 0 + def start_mft(): print("Setting up MFT Services") @@ -164,13 +164,15 @@ 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...") + for _ in range(20): + if is_consul_running(): + restart_service(path + "/bin", "standalone-service-daemon.sh") + print("MFT Started") + return time.sleep(1) + print("Consul is not running. Quitting...") + raise typer.Exit() - restart_service(path + "/bin", "standalone-service-daemon.sh") - - print("MFT Started") def stop_mft():
