Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation logic to wait until the consul port 8500 is open before starting mft (issue #128) #131

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions python-cli/mft_cli/airavata_mft_cli/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
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/")):
Expand Down Expand Up @@ -105,7 +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_consul_running():
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
return s.connect_ex(('localhost', 8500)) == 0

def start_mft():
print("Setting up MFT Services")

Expand Down Expand Up @@ -160,9 +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)

restart_service(path + "/bin", "standalone-service-daemon.sh")
for _ in range(20):
if is_consul_running():
restart_service(path + "/bin", "standalone-service-daemon.sh")
print("MFT Started")
return
time.sleep(1)
ShivangMishra marked this conversation as resolved.
Show resolved Hide resolved
print("Consul is not running. Quitting...")
raise typer.Exit()

print("MFT Started")


def stop_mft():
Expand Down