Update server.py
Browse files
server.py
CHANGED
|
@@ -90,6 +90,7 @@ st_status = True
|
|
| 90 |
import subprocess
|
| 91 |
import os
|
| 92 |
import sys
|
|
|
|
| 93 |
from IPython.display import clear_output
|
| 94 |
import urllib.request
|
| 95 |
from pathlib import Path
|
|
@@ -597,8 +598,14 @@ def monitor_port():
|
|
| 597 |
print(f"端口 8000 正在使用中")
|
| 598 |
else:
|
| 599 |
print(f"端口 8000 未被使用")
|
| 600 |
-
|
| 601 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 602 |
# 启动脚本并在后台运行
|
| 603 |
# try:
|
| 604 |
# os.chdir(data_folder)
|
|
@@ -708,6 +715,17 @@ threading.Thread(target=SillyTavern, daemon=True).start()
|
|
| 708 |
time.sleep(60)
|
| 709 |
check_api1()
|
| 710 |
os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 711 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 712 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 713 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|
|
|
|
| 90 |
import subprocess
|
| 91 |
import os
|
| 92 |
import sys
|
| 93 |
+
import configparser
|
| 94 |
from IPython.display import clear_output
|
| 95 |
import urllib.request
|
| 96 |
from pathlib import Path
|
|
|
|
| 598 |
print(f"端口 8000 正在使用中")
|
| 599 |
else:
|
| 600 |
print(f"端口 8000 未被使用")
|
| 601 |
+
config = configparser.ConfigParser()
|
| 602 |
+
config.read('/config.ini')
|
| 603 |
+
monitor_port_enabled = config.getboolean('general', 'monitor_port_enabled', fallback=False)
|
| 604 |
+
if monitor_port_enabled:
|
| 605 |
+
backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
|
| 606 |
+
backup_thread.start()
|
| 607 |
+
else:
|
| 608 |
+
print(f"monitor_port_enabled 为False跳过")
|
| 609 |
# 启动脚本并在后台运行
|
| 610 |
# try:
|
| 611 |
# os.chdir(data_folder)
|
|
|
|
| 715 |
time.sleep(60)
|
| 716 |
check_api1()
|
| 717 |
os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
|
| 718 |
+
|
| 719 |
+
# 创建 ConfigParser 对象
|
| 720 |
+
config = configparser.ConfigParser()
|
| 721 |
+
# 添加一个 'general' 部分
|
| 722 |
+
config.add_section('general')
|
| 723 |
+
# 设置 'monitor_port_enabled' 选项的值为 True
|
| 724 |
+
config.set('general', 'monitor_port_enabled', 'True')
|
| 725 |
+
# 将配置写入到 'config.ini' 文件中
|
| 726 |
+
with open('/config.ini', 'w') as configfile:
|
| 727 |
+
config.write(configfile)
|
| 728 |
+
|
| 729 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 730 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 731 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|