Skip to content

Commit

Permalink
Loop every sec for 10sec for confg server to be up
Browse files Browse the repository at this point in the history
  • Loading branch information
abuabraham-ttd committed Dec 11, 2024
1 parent 77f1f4a commit a4241fc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/aws/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,25 @@ def _setup_auxiliaries(self) -> None:
self.__setup_vsockproxy(log_level)
self.__run_config_server()
self.__run_socks_proxy()
time.sleep(5) #TODO: Change to while loop if required.

def _validate_auxiliaries(self) -> None:
"""Validates connection to flask server direct and through socks proxy."""
proxy = "socks5://127.0.0.1:3306"
config_url = "http://127.0.0.1:27015/getConfig"
try:
response = requests.get(config_url)
for attempt in range(10):
try:
response = requests.get(config_url)
print("Config server is reachable")
break
except requests.exceptions.ConnectionError as e:
print(f"Connecting to config server, attempt {attempt + 1} failed with ConnectionError: {e}")
time.sleep(1)
else:
raise RuntimeError(f"Config server unreachable")
response.raise_for_status()
except requests.RequestException as e:
raise RuntimeError(f"Config server unreachable: {e}")
raise RuntimeError(f"Failed to get config from config server: {e}")
proxies = {"http": proxy, "https": proxy}
try:
response = requests.get(config_url, proxies=proxies)
Expand Down

0 comments on commit a4241fc

Please sign in to comment.