File size: 1,416 Bytes
4c60780 | 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 | import subprocess
import sys
import time
import os
def run_webui():
user_args = sys.argv[1:]
python_exe = "/content/venv/GUTRIS1/bin/python3.10"
command = [python_exe, "launch.py"] + user_args
attempt = 1
while True:
print(f"\nπ [{attempt}νμ°¨] WebUI μ€ν μλ...")
process = subprocess.Popen(
command,
env=os.environ.copy(),
cwd="/content/stable-diffusion-webui-reForge"
)
try:
# νλ‘μΈμ€κ° λλ λκΉμ§ λκΈ°
return_code = process.wait()
if return_code != 0:
print(f"\nβ μλ¬ λ°μ (Exit Code: {return_code}). 2μ΄ ν μλ μ¬μμ...")
attempt += 1
time.sleep(2)
continue
else:
print("\nβ
WebUI μ μ μ’
λ£.")
break
except KeyboardInterrupt:
# μ¬μ©μκ° Ctrl+Cλ₯Ό λλ μ λ
print("\n\nπ μ¬μ©μκ° μ€λ¨ μ νΈλ₯Ό 보λμ΅λλ€. μμ νκ² μ’
λ£ν©λλ€...")
process.terminate() # μμ νλ‘μΈμ€(WebUI)λ κ°μ΄ μ£½μ¬μ€
try:
process.wait(timeout=5)
except:
process.kill()
print("β
WebUI μ’
λ£ μλ£.")
break # 루ν νμΆ
if __name__ == "__main__":
run_webui()
|