Complete Task 1: Deploy and Monitoring
هذا الالتزام موجود في:
22
q1-deploy-monitor/monitor.py
Normal file
22
q1-deploy-monitor/monitor.py
Normal file
@@ -0,0 +1,22 @@
|
||||
import time
|
||||
import requests
|
||||
|
||||
URL = "http://localhost:5000/health"
|
||||
|
||||
while True:
|
||||
start = time.time()
|
||||
|
||||
try:
|
||||
response = requests.get(URL, timeout=5)
|
||||
|
||||
response_time = (time.time() - start) * 1000
|
||||
|
||||
print(
|
||||
f"[OK] Status: {response.status_code} | "
|
||||
f"Response Time: {response_time:.2f} ms"
|
||||
)
|
||||
|
||||
except requests.exceptions.RequestException:
|
||||
print("[DOWN] Service is unavailable")
|
||||
|
||||
time.sleep(30)
|
||||
المرجع في مشكلة جديدة
حظر مستخدم