arcacolab commited on
Commit
e643bdd
ยท
verified ยท
1 Parent(s): 5effe80

Upload reforge_launcher.py

Browse files
Files changed (1) hide show
  1. reforge_launcher.py +38 -0
reforge_launcher.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import sys
3
+ import time
4
+ import os
5
+
6
+ def run_webui():
7
+ user_args = sys.argv[1:]
8
+ python_exe = "/content/venv/GUTRIS1/bin/python3.10"
9
+ command = [python_exe, "launch.py"] + user_args
10
+
11
+ attempt = 1
12
+ while True:
13
+ print(f"\n๐Ÿš€ [{attempt}ํšŒ์ฐจ] WebUI ์‹คํ–‰ ์‹œ๋„...")
14
+
15
+ # stdout=None์œผ๋กœ ์„ค์ •ํ•˜๋ฉด ์‹œ์Šคํ…œ์ด ์ง์ ‘ ๋กœ๊ทธ๋ฅผ ์ฐ์œผ๋ฏ€๋กœ ์†๋„ ์ €ํ•˜๊ฐ€ 0์ž…๋‹ˆ๋‹ค.
16
+ process = subprocess.Popen(
17
+ command,
18
+ env=os.environ.copy(),
19
+ cwd="/content/stable-diffusion-webui-reForge"
20
+ )
21
+
22
+ # ํ”„๋กœ์„ธ์Šค๊ฐ€ ๋๋‚  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฝ๋‹ˆ๋‹ค.
23
+ return_code = process.wait()
24
+
25
+ # ๋งŒ์•ฝ ์—๋Ÿฌ ์ฝ”๋“œ๋ฅผ ๋‚จ๊ธฐ๊ณ  ์ฃฝ์—ˆ๋‹ค๋ฉด (๋ณดํ†ต 1) ์ž๋™์œผ๋กœ ์žฌ์‹œ์ž‘
26
+ if return_code != 0:
27
+ print(f"\nโŒ ์—๋Ÿฌ ๋ฐœ์ƒ (Exit Code: {return_code}). 2์ดˆ ํ›„ ์ž๋™ ์žฌ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค...")
28
+ attempt += 1
29
+ time.sleep(2)
30
+ continue
31
+ else:
32
+ # ์ •์ƒ ์ข…๋ฃŒ(0)์ธ ๊ฒฝ์šฐ ๋ฃจํ”„ ํƒˆ์ถœ
33
+ print("\nโœ… WebUI ์ข…๋ฃŒ.")
34
+ break
35
+
36
+ if __name__ == "__main__":
37
+ run_webui()
38
+