mirror of
https://github.com/StefBuwalda/dashboard_test.git
synced 2025-10-30 11:19:58 +00:00
Split up the updating of service status and serving requests into two threads.
This commit is contained in:
24
poll_services.py
Normal file
24
poll_services.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from mem import services
|
||||
import requests
|
||||
import urllib3
|
||||
import time
|
||||
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
|
||||
def update_services() -> None:
|
||||
print("Updating Service Status")
|
||||
while True:
|
||||
for s in services:
|
||||
try:
|
||||
r = requests.head(
|
||||
url=s.url,
|
||||
verify=s.public,
|
||||
allow_redirects=True,
|
||||
timeout=1,
|
||||
)
|
||||
s.set_status(r.ok)
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(e)
|
||||
s.set_status(False)
|
||||
time.sleep(3)
|
||||
Reference in New Issue
Block a user