VINU NAYAK commited on
Commit
694f46a
·
verified ·
1 Parent(s): de56693

Delete check_server.py

Browse files
Files changed (1) hide show
  1. check_server.py +0 -68
check_server.py DELETED
@@ -1,68 +0,0 @@
1
- import requests
2
- import sys
3
- import time
4
-
5
- def check_server(url="http://localhost:7860", max_retries=5, retry_delay=2):
6
- """
7
- Check if the server is running by making a request to the root URL.
8
-
9
- Args:
10
- url (str): The URL to check
11
- max_retries (int): Maximum number of retry attempts
12
- retry_delay (int): Delay between retries in seconds
13
-
14
- Returns:
15
- bool: True if the server is running, False otherwise
16
- """
17
- print(f"Checking if server is running at {url}...")
18
-
19
- for i in range(max_retries):
20
- try:
21
- response = requests.get(url)
22
- if response.status_code == 200:
23
- print(f"Server is running! Status code: {response.status_code}")
24
- return True
25
- else:
26
- print(f"Server returned status code {response.status_code}, retrying ({i+1}/{max_retries})...")
27
- except requests.exceptions.ConnectionError:
28
- print(f"Connection error, retrying ({i+1}/{max_retries})...")
29
-
30
- # Wait before retrying
31
- time.sleep(retry_delay)
32
-
33
- print(f"Server is not running after {max_retries} attempts.")
34
- return False
35
-
36
- def check_health(url="http://localhost:7860/health"):
37
- """
38
- Check the health endpoint of the server.
39
-
40
- Args:
41
- url (str): The health endpoint URL
42
-
43
- Returns:
44
- dict: The health check response or None if failed
45
- """
46
- try:
47
- response = requests.get(url)
48
- if response.status_code == 200:
49
- health_data = response.json()
50
- print("Health check successful!")
51
- print(f"Python version: {health_data.get('python_version', 'unknown')}")
52
- print(f"System: {health_data.get('system', 'unknown')}")
53
- print("Dependencies:")
54
- for dep, status in health_data.get('dependencies', {}).items():
55
- print(f" - {dep}: {status}")
56
- return health_data
57
- else:
58
- print(f"Health check failed with status code: {response.status_code}")
59
- return None
60
- except Exception as e:
61
- print(f"Error checking health: {str(e)}")
62
- return None
63
-
64
- if __name__ == "__main__":
65
- base_url = sys.argv[1] if len(sys.argv) > 1 else "http://localhost:7860"
66
-
67
- if check_server(base_url):
68
- check_health(f"{base_url}/health")