Qilan2 commited on
Commit
6df7ee0
·
verified ·
1 Parent(s): 7fed372

Update server2.py

Browse files
Files changed (1) hide show
  1. server2.py +21 -2
server2.py CHANGED
@@ -89,6 +89,7 @@ st_status = True
89
  import subprocess
90
  import os
91
  import sys
 
92
  from IPython.display import clear_output
93
  import urllib.request
94
  from pathlib import Path
@@ -584,8 +585,15 @@ def monitor_port():
584
  print(f"端口 8000 正在使用中")
585
  else:
586
  print(f"端口 8000 未被使用")
587
- backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
588
- backup_thread.start()
 
 
 
 
 
 
 
589
  # 启动脚本并在后台运行
590
  # try:
591
  # os.chdir(data_folder)
@@ -692,6 +700,17 @@ threading.Thread(target=SillyTavern, daemon=True).start()
692
  time.sleep(60)
693
  check_api1()
694
  os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
 
 
 
 
 
 
 
 
 
 
 
695
  if os.path.exists(f'{data_folder}/start.sh'):
696
  replace_info_in_file(f'{data_folder}/public/login.html')
697
  backup_thread = threading.Thread(target=repeat_task, daemon=True)#压缩备份
 
89
  import subprocess
90
  import os
91
  import sys
92
+ import configparser
93
  from IPython.display import clear_output
94
  import urllib.request
95
  from pathlib import Path
 
585
  print(f"端口 8000 正在使用中")
586
  else:
587
  print(f"端口 8000 未被使用")
588
+ # 读取 config.ini 中的 monitor_port_enabled 配置项
589
+ config = configparser.ConfigParser()
590
+ config.read('/config.ini')
591
+ monitor_port_enabled = config.getboolean('general', 'monitor_port_enabled', fallback=False)
592
+ if monitor_port_enabled:
593
+ backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
594
+ backup_thread.start()
595
+ else:
596
+ print(f"monitor_port_enabled 为False跳过")
597
  # 启动脚本并在后台运行
598
  # try:
599
  # os.chdir(data_folder)
 
700
  time.sleep(60)
701
  check_api1()
702
  os.system("rm -r /qilan-st2.zip /sillytavern.tar.gz")
703
+
704
+ # 创建 ConfigParser 对象
705
+ config = configparser.ConfigParser()
706
+ # 添加一个 'general' 部分
707
+ config.add_section('general')
708
+ # 设置 'monitor_port_enabled' 选项的值为 True
709
+ config.set('general', 'monitor_port_enabled', 'True')
710
+ # 将配置写入到 'config.ini' 文件中
711
+ with open('/config.ini', 'w') as configfile:
712
+ config.write(configfile)
713
+
714
  if os.path.exists(f'{data_folder}/start.sh'):
715
  replace_info_in_file(f'{data_folder}/public/login.html')
716
  backup_thread = threading.Thread(target=repeat_task, daemon=True)#压缩备份