Update server2.py
Browse files- server2.py +12 -4
server2.py
CHANGED
|
@@ -452,8 +452,9 @@ def replace_ip_and_country_in_file(file_path):
|
|
| 452 |
print(f"发生其他错误: {e}")
|
| 453 |
|
| 454 |
import socket
|
| 455 |
-
import
|
| 456 |
import time
|
|
|
|
| 457 |
def monitor_port():
|
| 458 |
while True:
|
| 459 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
@@ -462,9 +463,16 @@ def monitor_port():
|
|
| 462 |
print(f"端口 8000 正在使用中")
|
| 463 |
else:
|
| 464 |
print(f"端口 8000 未被使用")
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 468 |
|
| 469 |
def SillyTavern():
|
| 470 |
print('-----------SillyTavern开始-------------')
|
|
|
|
| 452 |
print(f"发生其他错误: {e}")
|
| 453 |
|
| 454 |
import socket
|
| 455 |
+
import subprocess
|
| 456 |
import time
|
| 457 |
+
|
| 458 |
def monitor_port():
|
| 459 |
while True:
|
| 460 |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
|
|
|
| 463 |
print(f"端口 8000 正在使用中")
|
| 464 |
else:
|
| 465 |
print(f"端口 8000 未被使用")
|
| 466 |
+
# 启动脚本并在后台运行
|
| 467 |
+
try:
|
| 468 |
+
process = subprocess.Popen('yes | sh /sillytavern/start.sh', shell=True)
|
| 469 |
+
print("已尝试启动 /sillytavern/start.sh")
|
| 470 |
+
time.sleep(20)
|
| 471 |
+
except Exception as e: # 捕获所有异常
|
| 472 |
+
print(f"命令失败: {e}")
|
| 473 |
+
|
| 474 |
+
time.sleep(5) # 每5秒检查一次
|
| 475 |
+
|
| 476 |
|
| 477 |
def SillyTavern():
|
| 478 |
print('-----------SillyTavern开始-------------')
|