Update server.py
Browse files
server.py
CHANGED
|
@@ -129,15 +129,27 @@ def sync2():
|
|
| 129 |
threading.Thread(target=sync2, daemon=True).start()
|
| 130 |
def sync():
|
| 131 |
commands = [
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
]
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
|
| 142 |
def requests_retry_session(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None):
|
| 143 |
"""创建一个带重试机制的请求会话"""
|
|
|
|
| 129 |
threading.Thread(target=sync2, daemon=True).start()
|
| 130 |
def sync():
|
| 131 |
commands = [
|
| 132 |
+
"rm -r /rsync.py /sync.sh",
|
| 133 |
+
"wget -O /rsync.py https://huggingface.co/datasets/Qilan2/st-server/resolve/main/rsync.py",
|
| 134 |
+
"wget -O /sync.sh https://huggingface.co/datasets/Qilan2/st-server/resolve/main/sync.sh",
|
| 135 |
+
"chmod +x /sync.sh",
|
| 136 |
+
"chmod +x /rsync.py"
|
| 137 |
+
]
|
| 138 |
+
|
| 139 |
+
for command in commands:
|
| 140 |
+
print(f"Running: {command}")
|
| 141 |
+
if os.system(command) != 0:
|
| 142 |
+
print("Command failed.")
|
| 143 |
+
return # 如果有命令失败,则退出函数
|
| 144 |
+
|
| 145 |
+
# 启动 sync.sh 脚本,并传递参数
|
| 146 |
+
process = subprocess.Popen(['sh', '/sync.sh', frp_url, ssh_port], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 147 |
+
|
| 148 |
+
stdout, stderr = process.communicate()
|
| 149 |
+
|
| 150 |
+
print("Output:", stdout.decode())
|
| 151 |
+
if stderr:
|
| 152 |
+
print("Error:", stderr.decode())
|
| 153 |
|
| 154 |
def requests_retry_session(retries=3, backoff_factor=0.3, status_forcelist=(500, 502, 504), session=None):
|
| 155 |
"""创建一个带重试机制的请求会话"""
|