Skip to content

Commit

Permalink
Merge pull request #73 from CanDIG/bugfix/heartbeat-dont-interrupt-loop
Browse files Browse the repository at this point in the history
Don't allow a failing server to interrupt the entire heartbeat
  • Loading branch information
daisieh authored Oct 18, 2024
2 parents 2a52429 + f2f9095 commit 8e502de
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions candig_federation/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ def check_pulse():
# Determine which sites we have access to
live_servers = []
log = ""
try:
for server in servers.values():
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)

# Determine whether or not those sites are available by pinging Federation service-info
with open('/app/federation/live_servers.txt', 'w') as f:
f.write("|".join(live_servers))
except Exception as e:
log += "\n" + str(e)
# Determine whether or not those sites are available by pinging Federation service-info
with open('/app/federation/live_servers.txt', 'w') as f:
f.write("|".join(live_servers))

with open('/app/federation/log.txt', 'w') as f:
f.write(log)
f.write(str(e))
with open('/app/federation/log.txt', 'w') as f:
f.write(log)
f.write(str(e))


def get_live_servers():
Expand Down

0 comments on commit 8e502de

Please sign in to comment.