Update server.py
Browse files
server.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
ini_content = {"username":"xovale7506","key":"502e30bafc004c02aa668a279df23f3e"}
|
|
|
|
| 2 |
config_data = """
|
| 3 |
[common]
|
| 4 |
server_addr = 8.217.96.17
|
|
@@ -138,33 +139,50 @@ def check_api1():
|
|
| 138 |
|
| 139 |
time.sleep(5) # 等待5秒后重试
|
| 140 |
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
| 168 |
|
| 169 |
|
| 170 |
def frp():
|
|
|
|
| 1 |
ini_content = {"username":"xovale7506","key":"502e30bafc004c02aa668a279df23f3e"}
|
| 2 |
+
st_url = 'http://8.217.96.17:7073'
|
| 3 |
config_data = """
|
| 4 |
[common]
|
| 5 |
server_addr = 8.217.96.17
|
|
|
|
| 139 |
|
| 140 |
time.sleep(5) # 等待5秒后重试
|
| 141 |
|
| 142 |
+
print('开始检测接口状态')
|
| 143 |
+
while True:
|
| 144 |
+
url = f"{sd_url}/v1"
|
| 145 |
+
try:
|
| 146 |
+
response = requests_retry_session().get(url, timeout=30)
|
| 147 |
+
response.raise_for_status() # 检查响应状态
|
| 148 |
+
|
| 149 |
+
# 检查返回的状态码
|
| 150 |
+
if response.status_code == 403:
|
| 151 |
+
print("SillyTavern已经启动")
|
| 152 |
+
break # 服务已启动,退出循环
|
| 153 |
+
|
| 154 |
+
# 尝试解析 JSON 响应
|
| 155 |
+
response_json = response.json()
|
| 156 |
+
|
| 157 |
+
# 检查返回信息是否包含特定内容
|
| 158 |
+
if "detail" in response_json and response_json["detail"] in ("Method Not Allowed", "Not Found"):
|
| 159 |
+
print("接口正常")
|
| 160 |
+
else:
|
| 161 |
+
print("接口返回信息:", response_json)
|
| 162 |
+
|
| 163 |
+
except requests.exceptions.HTTPError as e:
|
| 164 |
+
if e.response.status_code == 403:
|
| 165 |
+
print("SillyTavern已经启动") # 再次确认服务已启动
|
| 166 |
+
break
|
| 167 |
+
|
| 168 |
+
print("接口正常2")
|
| 169 |
+
|
| 170 |
+
except requests.exceptions.ConnectionError as e:
|
| 171 |
+
print(f"接口异常1: {e}")
|
| 172 |
+
threading.Thread(target=Frpc, daemon=True).start()
|
| 173 |
+
break
|
| 174 |
+
|
| 175 |
+
except requests.exceptions.Timeout as e:
|
| 176 |
+
print(f"接口异常2: {e}")
|
| 177 |
+
threading.Thread(target=Frpc, daemon=True).start()
|
| 178 |
+
break
|
| 179 |
|
| 180 |
+
except requests.exceptions.RequestException as e:
|
| 181 |
+
print(f"接口异常3: {e}")
|
| 182 |
+
threading.Thread(target=Frpc, daemon=True).start()
|
| 183 |
+
break
|
| 184 |
+
|
| 185 |
+
time.sleep(5) # 等待5秒后重试
|
| 186 |
|
| 187 |
|
| 188 |
def frp():
|