Update server5.py
Browse files- server5.py +20 -2
server5.py
CHANGED
|
@@ -84,6 +84,7 @@ st_status = True
|
|
| 84 |
import subprocess
|
| 85 |
import os
|
| 86 |
import sys
|
|
|
|
| 87 |
from IPython.display import clear_output
|
| 88 |
import urllib.request
|
| 89 |
from pathlib import Path
|
|
@@ -588,8 +589,15 @@ def monitor_port():
|
|
| 588 |
print(f"端口 8000 正在使用中")
|
| 589 |
else:
|
| 590 |
print(f"端口 8000 未被使用")
|
| 591 |
-
|
| 592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 593 |
time.sleep(5) # 每5秒检查一次
|
| 594 |
def Run_SillyTavern():
|
| 595 |
|
|
@@ -688,6 +696,16 @@ threading.Thread(target=SillyTavern, daemon=True).start()
|
|
| 688 |
time.sleep(60)
|
| 689 |
check_api1()
|
| 690 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 691 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 692 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 693 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|
|
|
|
| 84 |
import subprocess
|
| 85 |
import os
|
| 86 |
import sys
|
| 87 |
+
import configparser
|
| 88 |
from IPython.display import clear_output
|
| 89 |
import urllib.request
|
| 90 |
from pathlib import Path
|
|
|
|
| 589 |
print(f"端口 8000 正在使用中")
|
| 590 |
else:
|
| 591 |
print(f"端口 8000 未被使用")
|
| 592 |
+
# 读取 config.ini 中的 monitor_port_enabled 配置项
|
| 593 |
+
config = configparser.ConfigParser()
|
| 594 |
+
config.read('/config.ini')
|
| 595 |
+
monitor_port_enabled = config.getboolean('general', 'monitor_port_enabled', fallback=False)
|
| 596 |
+
if monitor_port_enabled:
|
| 597 |
+
backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
|
| 598 |
+
backup_thread.start()
|
| 599 |
+
else:
|
| 600 |
+
print(f"monitor_port_enabled 为False跳过")
|
| 601 |
time.sleep(5) # 每5秒检查一次
|
| 602 |
def Run_SillyTavern():
|
| 603 |
|
|
|
|
| 696 |
time.sleep(60)
|
| 697 |
check_api1()
|
| 698 |
|
| 699 |
+
|
| 700 |
+
# 创建 ConfigParser 对象
|
| 701 |
+
config = configparser.ConfigParser()
|
| 702 |
+
# 添加一个 'general' 部分
|
| 703 |
+
config.add_section('general')
|
| 704 |
+
# 设置 'monitor_port_enabled' 选项的值为 True
|
| 705 |
+
config.set('general', 'monitor_port_enabled', 'True')
|
| 706 |
+
# 将配置写入到 'config.ini' 文件中
|
| 707 |
+
with open('/config.ini', 'w') as configfile:
|
| 708 |
+
config.write(configfile)
|
| 709 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 710 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 711 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|