Update server.py
Browse files
server.py
CHANGED
|
@@ -155,13 +155,11 @@ def copy_public_key_to_remote(host, port, user, password):
|
|
| 155 |
|
| 156 |
except Exception as e:
|
| 157 |
print(f"An error occurred: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
def sync():
|
| 159 |
-
# 生成 SSH 密钥对
|
| 160 |
-
generate_ssh_key()
|
| 161 |
-
# 复制公钥到远程服务器
|
| 162 |
-
copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
|
| 163 |
-
|
| 164 |
-
# 启动 sync.sh 脚本,并传递参数
|
| 165 |
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
|
| 166 |
|
| 167 |
|
|
@@ -223,9 +221,11 @@ def check_api1():
|
|
| 223 |
except requests.exceptions.HTTPError as e:
|
| 224 |
if e.response.status_code == 403:
|
| 225 |
print("接口正常2") # 再次确认服务已启动
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
| 229 |
break
|
| 230 |
|
| 231 |
print("接口正常3")
|
|
@@ -306,7 +306,7 @@ def SillyTavern():
|
|
| 306 |
# ]
|
| 307 |
# run_commands(commands)
|
| 308 |
# SillyTavern()
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
sync()
|
|
|
|
| 155 |
|
| 156 |
except Exception as e:
|
| 157 |
print(f"An error occurred: {e}")
|
| 158 |
+
# 生成 SSH 密钥对
|
| 159 |
+
generate_ssh_key()
|
| 160 |
+
# 复制公钥到远程服务器
|
| 161 |
+
copy_public_key_to_remote(frp_url, ssh_port, "root", "qilan")
|
| 162 |
def sync():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
|
| 164 |
|
| 165 |
|
|
|
|
| 221 |
except requests.exceptions.HTTPError as e:
|
| 222 |
if e.response.status_code == 403:
|
| 223 |
print("接口正常2") # 再次确认服务已启动
|
| 224 |
+
subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
|
| 225 |
+
# if thread_started:
|
| 226 |
+
# subprocess.run(f"rsync -avz -e 'ssh -p {ssh_port} -o StrictHostKeyChecking=no' root@{frp_url}:/sillytavern/ /sillytavern/", shell=True, check=True)
|
| 227 |
+
# threading.Thread(target=sync, daemon=True).start()
|
| 228 |
+
# thread_started = True # 设置标志为 True,表示线程已经启动过了
|
| 229 |
break
|
| 230 |
|
| 231 |
print("接口正常3")
|
|
|
|
| 306 |
# ]
|
| 307 |
# run_commands(commands)
|
| 308 |
# SillyTavern()
|
| 309 |
+
threading.Thread(target=SillyTavern, daemon=True).start()
|
| 310 |
+
check_api1()
|
| 311 |
+
frp()
|
| 312 |
+
# sync()
|