Added a questionable ping and changed HTTP head to get

This commit is contained in:
2025-08-29 23:18:36 +02:00
parent 8e794ec7f5
commit 877fce9b7a
2 changed files with 22 additions and 4 deletions

View File

@@ -2,24 +2,29 @@ from mem import services, service
import httpx
import urllib3
import asyncio
import time
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
async def check_service(client: httpx.AsyncClient, s: service):
try:
r = await client.head(
before = time.perf_counter()
r = await client.get(
url=s.url,
follow_redirects=True,
timeout=1,
)
after = time.perf_counter()
s.set_error(None)
s.set_online(r.status_code == 200)
s.set_status(r.status_code)
s.set_ping(int((after - before) * 1000))
except httpx.HTTPError as e:
s.set_error(str(e))
s.set_online(False)
s.set_status(None)
s.set_ping(None)
def start_async_loop():