File size: 2,469 Bytes
73b1fed
642ad73
 
1b15751
e89b82e
 
1b15751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d21685
238fe32
a031003
373962b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12ef190
 
9cefd9a
6d21685
f3b9358
238fe32
12ef190
 
 
6d21685
 
12ef190
6d21685
12ef190
6d21685
12ef190
642ad73
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import subprocess
from modules import launch_utils
import pyngrok
from pathlib import Path


#ngrok穿透
ngrok_use = True
ngrokTokenFile='/bushu/Authtoken.txt' # 非必填 存放ngrokToken的文件的路径

#ngrok
def ngrok_start(ngrokTokenFile: str, port: int, address_name: str, should_run: bool):
    if not should_run:
        print('Skipping ngrok start')
        return
    if Path(ngrokTokenFile).exists():
        with open(ngrokTokenFile, encoding="utf-8") as nkfile:
            ngrokToken = nkfile.readline()
        print('use nrgok')
        from pyngrok import conf, ngrok
        conf.get_default().auth_token = ngrokToken
        conf.get_default().monitor_thread = False
        ssh_tunnels = ngrok.get_tunnels(conf.get_default())
        if len(ssh_tunnels) == 0:
            ssh_tunnel = ngrok.connect(port, bind_tls=True)
            print(f'{address_name}:' + ssh_tunnel.public_url)
        else:
            print(f'{address_name}:' + ssh_tunnels[0].public_url)
    else:
        print('skip start ngrok')


args = launch_utils.args
python = launch_utils.python
git = launch_utils.git
index_url = launch_utils.index_url
dir_repos = launch_utils.dir_repos

commit_hash = launch_utils.commit_hash
git_tag = launch_utils.git_tag

run = launch_utils.run
is_installed = launch_utils.is_installed
repo_dir = launch_utils.repo_dir

run_pip = launch_utils.run_pip
check_run_python = launch_utils.check_run_python
git_clone = launch_utils.git_clone
git_pull_recursive = launch_utils.git_pull_recursive
list_extensions = launch_utils.list_extensions
run_extension_installer = launch_utils.run_extension_installer
prepare_environment = launch_utils.prepare_environment
configure_for_tests = launch_utils.configure_for_tests
start = launch_utils.start

def run_command(command):
    subprocess.run(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def main():
    ngrok_start(ngrokTokenFile,7860,'use ngrok',ngrok_use)
    if not args.skip_prepare_environment:
        launch_utils.prepare_environment()
        run_command(f"""sed -i -e ''"s/dict()))/dict())).cuda()/g"'' /bushu/ui/repositories/stable-diffusion-stability-ai/ldm/util.py""")
        run_command(f"""sed -i -e ''"s/stable/dict()))/dict())).cuda()/g"'' /bushu/ui/repositories/diffusion-stability-stable/ldm/util.py""")

    if args.test_server:
        launch_utils.configure_for_tests()

    launch_utils.start()

if __name__ == "__main__":
    main()