Qilan2 commited on
Commit
a8ee64c
·
verified ·
1 Parent(s): 6a8502a

Update server2.py

Browse files
Files changed (1) hide show
  1. server2.py +10 -39
server2.py CHANGED
@@ -324,51 +324,22 @@ def check_api1():
324
  break
325
  url = f"{st_url}/csrf-token" # 确保这个 URL 是正确的
326
  try:
327
- response = requests_retry_session().get(url, timeout=30)
328
- response.raise_for_status() # 检查响应状态
329
- # 尝试解析 JSON 响应
330
- response_json = response.json() # 获取 JSON 内容
331
- print(url,"接口返回信息:", response_json)
332
  if "token" in response_json:
333
  print("检测到 token")
334
- while True:
335
- try:
336
- # 启动 inotifywait 并读取输出
337
- process = subprocess.Popen(
338
- ["inotifywait", "-r", "-e", "modify,create,delete", "--format", "%w%f"],
339
- stdout=subprocess.PIPE,
340
- stderr=subprocess.PIPE,
341
- text=True
342
- )
343
-
344
- for output in iter(process.stdout.readline, ""):
345
- print(f"检测到文件变化: {output.strip()}")
346
-
347
- # 执行 rsync 同步操作
348
- rsync_command = [
349
- "rsync",
350
- "-avz",
351
- "-e",
352
- f"ssh -p {ssh_port} -o StrictHostKeyChecking=no",
353
- f"root@{frp_url}:/sillytavern/",
354
- "/sillytavern/"
355
- ]
356
-
357
- subprocess.run(rsync_command, check=True)
358
-
359
- except Exception as e:
360
- print(f"发生错误: {e}")
361
- # try:
362
- # subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
363
- # except subprocess.CalledProcessError as e:
364
- # print(f"Rsync failed with return code: {e.returncode}")
365
- # print(f"Command output: {e.output}")
366
-
367
  # subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
368
  # break # 跳出循环
369
  else:
370
  print("接口返回信息:", response_json)
371
-
 
 
 
 
372
  except requests.exceptions.ConnectionError as e:
373
  print(f"接口异常1: {e}")
374
  # threading.Thread(target=Frpc, daemon=True).start()
 
324
  break
325
  url = f"{st_url}/csrf-token" # 确保这个 URL 是正确的
326
  try:
 
 
 
 
 
327
  if "token" in response_json:
328
  print("检测到 token")
329
+ try:
330
+ subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
331
+ except subprocess.CalledProcessError as e:
332
+ print(f"Rsync failed with return code: {e.returncode}")
333
+ print(f"Command output: {e.output}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
334
  # subprocess.run(f"bash /sync.sh -p {ssh_port} -s {frp_url}", shell=True, check=True)
335
  # break # 跳出循环
336
  else:
337
  print("接口返回信息:", response_json)
338
+ response = requests_retry_session().get(url, timeout=30)
339
+ response.raise_for_status() # 检查响应状态
340
+ # 尝试解析 JSON 响应
341
+ response_json = response.json() # 获取 JSON 内容
342
+ print(url,"接口返回信息:", response_json)
343
  except requests.exceptions.ConnectionError as e:
344
  print(f"接口异常1: {e}")
345
  # threading.Thread(target=Frpc, daemon=True).start()