feat(bootstrap): when start mft, quit if consul does not start after 20 second wait
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 @@
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 @@
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():