Upload reforge_launcher.py
Browse files- 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 |
+
|