Improve uptime kuma logging
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 7s

This commit is contained in:
Nexus 2024-05-01 20:18:38 +01:00
parent 99ae3035d8
commit 446defea2c
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -50,10 +50,16 @@ class KumaThread(KillableThread):
start_time = time.time()
try:
self.retries += 1
response = client.get(self.url)
url = self.url
if url.endswith("ping="):
url += str(round(bot.latency, 2))
if bot.is_ready() is False:
url = url.replace("status=up", "status=down")
url = url.replace("msg=OK", "msg=Bot%20not%20ready")
response = client.get(url)
response.raise_for_status()
except httpx.HTTPError as error:
self.log.error("Failed to connect to uptime-kuma: %r: %r", self.url, error, exc_info=error)
self.log.error("Failed to connect to uptime-kuma: %r: %r", url, error, exc_info=error)
timeout = self.calculate_backoff()
self.log.warning("Waiting %d seconds before retrying ping.", timeout)
time.sleep(timeout)
@ -140,6 +146,7 @@ for module in CONFIG["jimmy"].get("modules", ["cogs/*.py"]):
else:
log.info(f"Loaded extension {module}")
@bot.event
async def on_ready():
log.info(f"Logged in as {bot.user} ({bot.user.id})")