Qilan2 commited on
Commit
7fed372
·
verified ·
1 Parent(s): 698684d

Update server3.py

Browse files
Files changed (1) hide show
  1. server3.py +21 -2
server3.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
@@ -569,8 +570,15 @@ def monitor_port():
569
  print(f"端口 8000 正在使用中")
570
  else:
571
  print(f"端口 8000 未被使用")
572
- backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
573
- backup_thread.start()
 
 
 
 
 
 
 
574
  # 启动脚本并在后台运行
575
  # try:
576
  # os.chdir(data_folder)
@@ -678,6 +686,17 @@ threading.Thread(target=SillyTavern, daemon=True).start()
678
  time.sleep(60)
679
  check_api1()
680
  os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
 
 
 
 
 
 
 
 
 
 
 
681
  if os.path.exists(f'{data_folder}/start.sh'):
682
  replace_info_in_file(f'{data_folder}/public/login.html')
683
  # 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
 
570
  print(f"端口 8000 正在使用中")
571
  else:
572
  print(f"端口 8000 未被使用")
573
+ # 读取 config.ini 中的 monitor_port_enabled 配置项
574
+ config = configparser.ConfigParser()
575
+ config.read('/config.ini')
576
+ monitor_port_enabled = config.getboolean('general', 'monitor_port_enabled', fallback=False)
577
+ if monitor_port_enabled:
578
+ backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
579
+ backup_thread.start()
580
+ else:
581
+ print(f"monitor_port_enabled 为False跳过")
582
  # 启动脚本并在后台运行
583
  # try:
584
  # os.chdir(data_folder)
 
686
  time.sleep(60)
687
  check_api1()
688
  os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
689
+
690
+ # 创建 ConfigParser 对象
691
+ config = configparser.ConfigParser()
692
+ # 添加一个 'general' 部分
693
+ config.add_section('general')
694
+ # 设置 'monitor_port_enabled' 选项的值为 True
695
+ config.set('general', 'monitor_port_enabled', 'True')
696
+ # 将配置写入到 'config.ini' 文件中
697
+ with open('/config.ini', 'w') as configfile:
698
+ config.write(configfile)
699
+
700
  if os.path.exists(f'{data_folder}/start.sh'):
701
  replace_info_in_file(f'{data_folder}/public/login.html')
702
  # threading.Thread(target=repeat_task, daemon=True).start() #压缩备份