Qilan2 commited on
Commit
582ba3b
·
verified ·
1 Parent(s): a20f502

Update server10v.py

Browse files
Files changed (1) hide show
  1. server10v.py +57 -49
server10v.py CHANGED
@@ -381,8 +381,11 @@ def SillyTavern():
381
 
382
  os.system(f"rm -rf /a /data/sillytavern /data/data /data/*.zip /data/*.ctk")
383
  # os.system(f"mkdir -p {data_folder}")
 
 
 
384
  os.chdir('/data')
385
- os.system("ls")
386
  print(f"kaggle datasets download {huggingface_name}/{huggingface_Data_name}")
387
  # os.system(f"kaggle datasets download {huggingface_name}/{huggingface_Data_name}")
388
  download_n = 0
@@ -406,6 +409,8 @@ def SillyTavern():
406
  else:
407
 
408
  # 如果文件存在,可以继续执行后续代码
 
 
409
  print(f"文件 /data/{huggingface_Data_name}.zip 存在,继续执行程序。")
410
  # # 解压 sillytavern.zip
411
  # os.system("rm *.zip")
@@ -419,7 +424,9 @@ def SillyTavern():
419
  os.system("mv /data/data/SillyTavern /data/SillyTavern")
420
 
421
  print('更新文件')
 
422
  os.chdir('/data/SillyTavern')
 
423
  os.system(f"ls {data_folder}")
424
  os.system("nvm install node")
425
  os.system("nvm use node")
@@ -431,8 +438,9 @@ def SillyTavern():
431
  print("Output:", e.output)
432
  os.system(f"ls {data_folder}")
433
  os.system("python /data/ip_huggingface.py")
434
- backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
435
- backup_thread.start()
 
436
  # os.system(f"rm -rf /a /data/sillytavern /data/data /data/*.zip /data/*.ctk")
437
 
438
  print('-----------SillyTavern结束-------------')
@@ -507,51 +515,51 @@ def check_system_resources():
507
  # 调用函数
508
 
509
 
510
- threading.Thread(target=SillyTavern, daemon=True).start()
511
- # SillyTavern()
512
- time.sleep(60)
513
- check_api1()
514
-
515
-
516
- # 创建 ConfigParser 对象
517
- config = configparser.ConfigParser()
518
- # 添加一个 'general' 部分
519
- config.add_section('general')
520
- # 设置 'monitor_port_enabled' 选项的值为 True
521
- config.set('general', 'monitor_port_enabled', 'True')
522
- # 将配置写入到 'config.ini' 文件中
523
- with open('/data/config.ini', 'w') as configfile:
524
- config.write(configfile)
525
- if os.path.exists(f'/data/{huggingface_Data_name}.zip'):
526
- os.system(f"rm -rf /a /data/data /data/*.zip /data/*.ctk /data/*.gz")
527
- backup_thread = threading.Thread(target=repeat_task, daemon=True)#压缩备份
528
- backup_thread.start()
529
- print("开始衔接")
530
- Service_status = True
531
- frp(configs, True)
532
- threading.Thread(target=monitor_port, daemon=True).start()#检测端口状态
533
- # check_system_resources()
534
- # time.sleep(600)
535
- while True:
536
- # 检查是否是中国时区早上6点
537
- china_tz = pytz.timezone('Asia/Shanghai')
538
- now = datetime.now(china_tz)
539
- if now.hour == 14 and now.minute < 2: # 6:00-6:05之间退出
540
- print(f"当前时间: {now.strftime('%Y-%m-%d %H:%M:%S')}, 到达早上6点,退出循环")
541
- break
542
- else:
543
- print(f"当前时间: {now.strftime('%Y-%m-%d %H:%M:%S')}, 未到达早上6点")
544
 
545
- if backup_thread.is_alive():
546
- print("备份线程仍在运行...")
547
- else:
548
- print("备份线程已停止.")
549
- backup_thread = threading.Thread(target=repeat_task, daemon=True)
550
- backup_thread.start()
551
- time.sleep(5)
552
- else:
553
- print(f'{data_folder}/start.sh 文件不存在结束执行')
554
- compress_folder()
555
- result = restart_huggingface_space(huggingface_user, huggingface_id, huggingface_tokon)
556
- print(result)
557
 
 
381
 
382
  os.system(f"rm -rf /a /data/sillytavern /data/data /data/*.zip /data/*.ctk")
383
  # os.system(f"mkdir -p {data_folder}")
384
+ print('----当前文件夹路径--------')
385
+ os.chdir('pwd')
386
+ print('----进入/data--------')
387
  os.chdir('/data')
388
+
389
  print(f"kaggle datasets download {huggingface_name}/{huggingface_Data_name}")
390
  # os.system(f"kaggle datasets download {huggingface_name}/{huggingface_Data_name}")
391
  download_n = 0
 
409
  else:
410
 
411
  # 如果文件存在,可以继续执行后续代码
412
+ print('----/data文件夹内容--------')
413
+ os.system("ls")
414
  print(f"文件 /data/{huggingface_Data_name}.zip 存在,继续执行程序。")
415
  # # 解压 sillytavern.zip
416
  # os.system("rm *.zip")
 
424
  os.system("mv /data/data/SillyTavern /data/SillyTavern")
425
 
426
  print('更新文件')
427
+ print('----进入/data/SillyTavern--------')
428
  os.chdir('/data/SillyTavern')
429
+ print('----/data/SillyTavern内容--------')
430
  os.system(f"ls {data_folder}")
431
  os.system("nvm install node")
432
  os.system("nvm use node")
 
438
  print("Output:", e.output)
439
  os.system(f"ls {data_folder}")
440
  os.system("python /data/ip_huggingface.py")
441
+ Run_SillyTavern()
442
+ # backup_thread = threading.Thread(target=Run_SillyTavern, daemon=True)
443
+ # backup_thread.start()
444
  # os.system(f"rm -rf /a /data/sillytavern /data/data /data/*.zip /data/*.ctk")
445
 
446
  print('-----------SillyTavern结束-------------')
 
515
  # 调用函数
516
 
517
 
518
+ # threading.Thread(target=SillyTavern, daemon=True).start()
519
+ SillyTavern()
520
+ # time.sleep(60)
521
+ # check_api1()
522
+
523
+
524
+ # # 创建 ConfigParser 对象
525
+ # config = configparser.ConfigParser()
526
+ # # 添加一个 'general' 部分
527
+ # config.add_section('general')
528
+ # # 设置 'monitor_port_enabled' 选项的值为 True
529
+ # config.set('general', 'monitor_port_enabled', 'True')
530
+ # # 将配置写入到 'config.ini' 文件中
531
+ # with open('/data/config.ini', 'w') as configfile:
532
+ # config.write(configfile)
533
+ # if os.path.exists(f'/data/{huggingface_Data_name}.zip'):
534
+ # os.system(f"rm -rf /a /data/data /data/*.zip /data/*.ctk /data/*.gz")
535
+ # backup_thread = threading.Thread(target=repeat_task, daemon=True)#压缩备份
536
+ # backup_thread.start()
537
+ # print("开始衔接")
538
+ # Service_status = True
539
+ # frp(configs, True)
540
+ # threading.Thread(target=monitor_port, daemon=True).start()#检测端口状态
541
+ # # check_system_resources()
542
+ # # time.sleep(600)
543
+ # while True:
544
+ # # 检查是否是中国时区早上6点
545
+ # china_tz = pytz.timezone('Asia/Shanghai')
546
+ # now = datetime.now(china_tz)
547
+ # if now.hour == 14 and now.minute < 2: # 6:00-6:05之间退出
548
+ # print(f"当前时间: {now.strftime('%Y-%m-%d %H:%M:%S')}, 到达早上6点,退出循环")
549
+ # break
550
+ # else:
551
+ # print(f"当前时间: {now.strftime('%Y-%m-%d %H:%M:%S')}, 未到达早上6点")
552
 
553
+ # if backup_thread.is_alive():
554
+ # print("备份线程仍在运行...")
555
+ # else:
556
+ # print("备份线程已停止.")
557
+ # backup_thread = threading.Thread(target=repeat_task, daemon=True)
558
+ # backup_thread.start()
559
+ # time.sleep(5)
560
+ # else:
561
+ # print(f'{data_folder}/start.sh 文件不存在结束执行')
562
+ # compress_folder()
563
+ # result = restart_huggingface_space(huggingface_user, huggingface_id, huggingface_tokon)
564
+ # print(result)
565