Update server4.py
Browse files- server4.py +22 -3
server4.py
CHANGED
|
@@ -569,8 +569,15 @@ def monitor_port():
|
|
| 569 |
print(f"端口 8000 正在使用中")
|
| 570 |
else:
|
| 571 |
print(f"端口 8000 未被使用")
|
| 572 |
-
|
| 573 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 574 |
# 启动脚本并在后台运行
|
| 575 |
# try:
|
| 576 |
# os.chdir(data_folder)
|
|
@@ -679,6 +686,18 @@ threading.Thread(target=SillyTavern, daemon=True).start()
|
|
| 679 |
time.sleep(60)
|
| 680 |
check_api1()
|
| 681 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 682 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 683 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 684 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|
|
@@ -688,7 +707,7 @@ if os.path.exists(f'{data_folder}/start.sh'):
|
|
| 688 |
Service_status = True
|
| 689 |
frp(configs, True)
|
| 690 |
# frp(config_data4,'/content/frp/frpc4.ini',True)
|
| 691 |
-
|
| 692 |
threading.Thread(target=monitor_port, daemon=True).start()#检测端口状态
|
| 693 |
while True:
|
| 694 |
if backup_thread.is_alive():
|
|
|
|
| 569 |
print(f"端口 8000 正在使用中")
|
| 570 |
else:
|
| 571 |
print(f"端口 8000 未被使用")
|
| 572 |
+
# 读取 config.ini 中的 monitor_port_enabled 配置项
|
| 573 |
+
config = configparser.ConfigParser()
|
| 574 |
+
config.read('/config.ini')
|
| 575 |
+
monitor_port_enabled = config.getboolean('general', 'monitor_port_enabled', fallback=False)
|
| 576 |
+
if monitor_port_enabled:
|
| 577 |
+
backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
|
| 578 |
+
backup_thread.start()
|
| 579 |
+
else:
|
| 580 |
+
print(f"monitor_port_enabled 为False跳过")
|
| 581 |
# 启动脚本并在后台运行
|
| 582 |
# try:
|
| 583 |
# os.chdir(data_folder)
|
|
|
|
| 686 |
time.sleep(60)
|
| 687 |
check_api1()
|
| 688 |
|
| 689 |
+
|
| 690 |
+
import configparser
|
| 691 |
+
# 创建 ConfigParser 对象
|
| 692 |
+
config = configparser.ConfigParser()
|
| 693 |
+
# 添加一个 'general' 部分
|
| 694 |
+
config.add_section('general')
|
| 695 |
+
# 设置 'monitor_port_enabled' 选项的值为 True
|
| 696 |
+
config.set('general', 'monitor_port_enabled', 'True')
|
| 697 |
+
# 将配置写入到 'config.ini' 文件中
|
| 698 |
+
with open('/config.ini', 'w') as configfile:
|
| 699 |
+
config.write(configfile)
|
| 700 |
+
|
| 701 |
if os.path.exists(f'{data_folder}/start.sh'):
|
| 702 |
replace_info_in_file(f'{data_folder}/public/login.html')
|
| 703 |
# threading.Thread(target=repeat_task, daemon=True).start() #压缩备份
|
|
|
|
| 707 |
Service_status = True
|
| 708 |
frp(configs, True)
|
| 709 |
# frp(config_data4,'/content/frp/frpc4.ini',True)
|
| 710 |
+
|
| 711 |
threading.Thread(target=monitor_port, daemon=True).start()#检测端口状态
|
| 712 |
while True:
|
| 713 |
if backup_thread.is_alive():
|