1+ #!/usr/bin/env python3
2+ import requests
3+ import time
4+ import sys
5+ from urllib3 .exceptions import InsecureRequestWarning
6+
7+ # Disable SSL warnings for localhost
8+ requests .packages .urllib3 .disable_warnings (InsecureRequestWarning )
9+
10+ def check_service_health (url , service_name , timeout = 120 ):
11+ """Check if a service is responding with HTTP 200"""
12+ print (f"🔍 Checking { service_name } at { url } ..." )
13+
14+ start_time = time .time ()
15+ while time .time () - start_time < timeout :
16+ try :
17+ print (f"Calling { url } ..." )
18+ response = requests .get (url , timeout = 10 , verify = False )
19+ if response .status_code == 200 :
20+ print (f"✅ { service_name } is responding (HTTP { response .status_code } )" )
21+ return True
22+ except requests .exceptions .RequestException as e :
23+ print ("Failed to call URL" , e )
24+ pass
25+
26+ print (f"⏳ Waiting for { service_name } ... ({ int (time .time () - start_time )} s)" )
27+ time .sleep (5 )
28+
29+ print (f"❌ { service_name } failed to respond after { timeout } s" )
30+ return False
31+
32+ def main ():
33+ services = [
34+ ("http://host.docker.internal/grafana" , "Grafana" ),
35+ ("http://host.docker.internal/prometheus" , "Prometheus" ),
36+ ("http://host.docker.internal/alloy" , "Prometheus" ),
37+ ]
38+
39+ all_healthy = True
40+ for url , name in services :
41+ if not check_service_health (url , name ):
42+ all_healthy = False
43+
44+ if all_healthy :
45+ print ("\n 🎉 All services are running successfully!" )
46+ print ("\n 📊 Access your services:" )
47+ return 0
48+ else :
49+ print ("\n ❌ Some services failed to start properly" )
50+ return 1
51+
52+ if __name__ == "__main__" :
53+ sys .exit (main ())
0 commit comments