arcacolab commited on
Commit
4c60780
Β·
verified Β·
1 Parent(s): 53b4d00

Upload reforge_launcher (1).py

Browse files
Files changed (1) hide show
  1. reforge_launcher (1).py +46 -0
reforge_launcher (1).py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ process = subprocess.Popen(
16
+ command,
17
+ env=os.environ.copy(),
18
+ cwd="/content/stable-diffusion-webui-reForge"
19
+ )
20
+
21
+ try:
22
+ # ν”„λ‘œμ„ΈμŠ€κ°€ 끝날 λ•ŒκΉŒμ§€ λŒ€κΈ°
23
+ return_code = process.wait()
24
+
25
+ if return_code != 0:
26
+ print(f"\n❌ μ—λŸ¬ λ°œμƒ (Exit Code: {return_code}). 2초 ν›„ μžλ™ μž¬μ‹œμž‘...")
27
+ attempt += 1
28
+ time.sleep(2)
29
+ continue
30
+ else:
31
+ print("\nβœ… WebUI 정상 μ’…λ£Œ.")
32
+ break
33
+
34
+ except KeyboardInterrupt:
35
+ # μ‚¬μš©μžκ°€ Ctrl+Cλ₯Ό λˆŒλ €μ„ λ•Œ
36
+ print("\n\nπŸ‘‹ μ‚¬μš©μžκ°€ 쀑단 μ‹ ν˜Έλ₯Ό λ³΄λƒˆμŠ΅λ‹ˆλ‹€. μ•ˆμ „ν•˜κ²Œ μ’…λ£Œν•©λ‹ˆλ‹€...")
37
+ process.terminate() # μžμ‹ ν”„λ‘œμ„ΈμŠ€(WebUI)도 같이 μ£½μ—¬μ€Œ
38
+ try:
39
+ process.wait(timeout=5)
40
+ except:
41
+ process.kill()
42
+ print("βœ… WebUI μ’…λ£Œ μ™„λ£Œ.")
43
+ break # 루프 νƒˆμΆœ
44
+
45
+ if __name__ == "__main__":
46
+ run_webui()