Skip to content

Commit

Permalink
assume that self works
Browse files Browse the repository at this point in the history
  • Loading branch information
daisieh committed Oct 18, 2024
1 parent e1e87b1 commit 2500592
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions candig_federation/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from network import get_registered_servers
import requests
import os.path
import os

def check_pulse():
servers = get_registered_servers()
Expand All @@ -12,14 +13,18 @@ def check_pulse():
live_servers = []
log = ""
for server in servers.values():
try:
url = f"{server['server']['url']}/hello"
log += f"\ntesting {url}"
service_info = requests.get(url, timeout=2)
if service_info.ok:
live_servers.append(server['server']['id'])
except Exception as e:
log += "\n" + str(e)
if server['server']['id'] != os.getenv("FEDERATION_SELF_SERVER_ID", 'internal-1'):
try:
url = f"{server['server']['url']}/hello"
log += f"\ntesting {url}"
service_info = requests.get(url, timeout=2)
if service_info.ok:
live_servers.append(server['server']['id'])
except Exception as e:
log += "\n" + str(e)
else:
live_servers.append(server['server']['id'])


# Determine whether or not those sites are available by pinging Federation service-info
with open('/app/federation/live_servers.txt', 'w') as f:
Expand Down

0 comments on commit 2500592

Please sign in to comment.