Wait a shorter amount of time to alert up
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 5s

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

View file

@ -35,6 +35,7 @@ class KumaThread(KillableThread):
self.interval = interval
self.kill = Event()
self.retries = 0
self.previous = False
def calculate_backoff(self) -> float:
rnd = random.uniform(0, 1)
@ -58,6 +59,7 @@ class KumaThread(KillableThread):
url = url.replace("msg=OK", "msg=Bot%20not%20ready")
response = client.get(url)
response.raise_for_status()
self.previous = bot.is_ready()
except httpx.HTTPError as error:
self.log.error("Failed to connect to uptime-kuma: %r: %r", url, error, exc_info=error)
timeout = self.calculate_backoff()
@ -68,6 +70,8 @@ class KumaThread(KillableThread):
self.retries = 0
end_time = time.time()
timeout = self.interval - (end_time - start_time)
if self.previous is False:
timeout = 10
self.kill.wait(timeout)