Qilan2 commited on
Commit
2db4fc8
·
verified ·
1 Parent(s): 0e1616a

Update server.py

Browse files
Files changed (1) hide show
  1. server.py +15 -17
server.py CHANGED
@@ -70,7 +70,7 @@ def update():
70
  os.system("pip install ruamel.yaml") # install ruamel.yaml to solve the import issue
71
  os.system("pip install pexpect")
72
  print('-----------更新软件包列表结束-------------')
73
- update()
74
  from ruamel.yaml import YAML
75
  clear_output(wait=True) # 清除输出
76
 
@@ -137,7 +137,7 @@ def ssh():
137
  os.system("service ssh restart ")
138
  os.system("export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | grep -v '/opt/conda/lib' | paste -sd ':') ")
139
  print('-----------SSH结束-------------')
140
- ssh()
141
  clear_output()
142
 
143
 
@@ -285,6 +285,9 @@ def check_api1():
285
  Service_status = False
286
  # 第二次检查接口状态
287
  while True:
 
 
 
288
  url = f"{st_url}/v1" # 确保这个 URL 是正确的
289
  try:
290
  response = requests_retry_session().get(url, timeout=30)
@@ -295,22 +298,17 @@ def check_api1():
295
  if "注册" in response_text or "账号" in response_text:
296
  print("检测到注册账号相关信息,结束检测")
297
  break # 跳出循环
298
- if "detail" in response_json and response_json["detail"] in ("Method Not Allowed", "Not Found"):
299
- print("接口正常1")
300
  else:
301
- print("接口返回信息:", response_json)
302
-
303
- except requests.exceptions.HTTPError as e:
304
- if Service_status:
305
- print("结束检测")
306
- break
307
- if e.response.status_code == 403:
308
- print("接口正常2") # 再次确认服务已启动
309
- try:
310
- subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
311
- except subprocess.CalledProcessError as e:
312
- print(f"Rsync failed with return code: {e.returncode}")
313
- print(f"Command output: {e.output}")
314
  # if thread_started:
315
  # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
316
  # threading.Thread(target=sync, daemon=True).start()
 
70
  os.system("pip install ruamel.yaml") # install ruamel.yaml to solve the import issue
71
  os.system("pip install pexpect")
72
  print('-----------更新软件包列表结束-------------')
73
+ # update()
74
  from ruamel.yaml import YAML
75
  clear_output(wait=True) # 清除输出
76
 
 
137
  os.system("service ssh restart ")
138
  os.system("export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | grep -v '/opt/conda/lib' | paste -sd ':') ")
139
  print('-----------SSH结束-------------')
140
+ # ssh()
141
  clear_output()
142
 
143
 
 
285
  Service_status = False
286
  # 第二次检查接口状态
287
  while True:
288
+ if Service_status:
289
+ print("结束检测")
290
+ break
291
  url = f"{st_url}/v1" # 确保这个 URL 是正确的
292
  try:
293
  response = requests_retry_session().get(url, timeout=30)
 
298
  if "注册" in response_text or "账号" in response_text:
299
  print("检测到注册账号相关信息,结束检测")
300
  break # 跳出循环
 
 
301
  else:
302
+ print("接口返回信息:", response_text)
303
+
304
+ # except requests.exceptions.HTTPError as e:
305
+ # if e.response.status_code == 403:
306
+ # print("接口正常2") # 再次确认服务已启动
307
+ # try:
308
+ # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
309
+ # except subprocess.CalledProcessError as e:
310
+ # print(f"Rsync failed with return code: {e.returncode}")
311
+ # print(f"Command output: {e.output}")
 
 
 
312
  # if thread_started:
313
  # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
314
  # threading.Thread(target=sync, daemon=True).start()