Skip to content

Commit

Permalink
add start event and make heartbeats more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Jan 17, 2024
1 parent a907be4 commit fec80ae
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@

HEARTBEAT_URL = os.getenv('HEARTBEAT_URL')

# Send a start signal to heartbeat
try:
requests.get(HEARTBEAT_URL + "/start", timeout=5)
except requests.exceptions.RequestException:
# If the network request fails for any reason, we don't want
# it to prevent the main job from running
pass

# Prepare discord connection
intents = nextcord.Intents.default()
intents.message_content = True
Expand Down Expand Up @@ -485,7 +493,13 @@ async def on_ready():

# Quit when done
print('Notifying the heartbeat check...')
requests.get(HEARTBEAT_URL)
try:
requests.get(HEARTBEAT_URL, timeout=10)
except requests.exceptions.RequestException:
# If the network request fails for any reason, we don't want
# it to prevent the main job from running
pass

print('Done. exiting.')
await client.close()

Expand Down

0 comments on commit fec80ae

Please sign in to comment.