BBrother commited on
Commit
373962b
1 Parent(s): 0ea881f

Update launch.py

Browse files
Files changed (1) hide show
  1. launch.py +39 -28
launch.py CHANGED
@@ -15,37 +15,48 @@ args.gradio_queue = True
15
  args.multiple = True
16
  args.no_download_sd_model = True
17
 
18
- # 设置日志文件路径
19
- log_file_path = '/bushu/logs_run.txt'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- # 配置日志
22
- logging.basicConfig(filename=log_file_path, level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
 
23
 
24
- # 创建一个将输出同时发送到控制台和日志文件的处理程序
25
- console_handler = logging.StreamHandler(sys.stdout)
26
- console_handler.setLevel(logging.INFO)
27
- formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
28
- console_handler.setFormatter(formatter)
29
- logging.getLogger().addHandler(console_handler)
30
 
31
- # 重定向标准输出和标准错误到日志文件和控制台
32
- sys.stdout = logging.getLogger().handlers[0].stream
33
- sys.stderr = logging.getLogger().handlers[0].stream
34
 
35
- try:
36
- if not args.skip_prepare_environment:
37
- launch_utils.prepare_environment()
38
- os.system(f"sed -i -e 's/dict()))/dict())).cuda()/g' {launch_utils.util_py_path}")
39
- os.system(f"sed -i -e 's/stable/dict()))/dict())).cuda()/g' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py")
40
 
41
  if args.test_server:
42
- launch_utils.configure_for_tests()
43
-
44
- launch_utils.start()
45
- except Exception as e:
46
- # 捕获其他异常并记录到日志文件
47
- logging.exception(f"程序发生异常: {e}")
48
- finally:
49
- # 最后,关闭日志处理程序,以确保所有日志都被写入到日志文件
50
- logging.getLogger().removeHandler(console_handler)
51
- console_handler.close()
 
15
  args.multiple = True
16
  args.no_download_sd_model = True
17
 
18
+ args = launch_utils.args
19
+ python = launch_utils.python
20
+ git = launch_utils.git
21
+ index_url = launch_utils.index_url
22
+ dir_repos = launch_utils.dir_repos
23
+
24
+ commit_hash = launch_utils.commit_hash
25
+ git_tag = launch_utils.git_tag
26
+
27
+ run = launch_utils.run
28
+ is_installed = launch_utils.is_installed
29
+ repo_dir = launch_utils.repo_dir
30
+
31
+ run_pip = launch_utils.run_pip
32
+ check_run_python = launch_utils.check_run_python
33
+ git_clone = launch_utils.git_clone
34
+ git_pull_recursive = launch_utils.git_pull_recursive
35
+ list_extensions = launch_utils.list_extensions
36
+ run_extension_installer = launch_utils.run_extension_installer
37
+ prepare_environment = launch_utils.prepare_environment
38
+ configure_for_tests = launch_utils.configure_for_tests
39
+ start = launch_utils.start
40
+
41
 
42
+ def main():
43
+ if args.dump_sysinfo:
44
+ filename = launch_utils.dump_sysinfo()
45
 
46
+ print(f"Sysinfo saved as {filename}. Exiting...")
 
 
 
 
 
47
 
48
+ exit(0)
 
 
49
 
50
+ launch_utils.startup_timer.record("initial startup")
51
+
52
+ with launch_utils.startup_timer.subcategory("prepare environment"):
53
+ if not args.skip_prepare_environment:
54
+ prepare_environment()
55
 
56
  if args.test_server:
57
+ configure_for_tests()
58
+
59
+ start()
60
+
61
+
62
+ main()