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 μ‹€ν–‰ μ‹œλ„...") # stdout=None으둜 μ„€μ •ν•˜λ©΄ μ‹œμŠ€ν…œμ΄ 직접 둜그λ₯Ό μ°μœΌλ―€λ‘œ 속도 μ €ν•˜κ°€ 0μž…λ‹ˆλ‹€. process = subprocess.Popen( command, env=os.environ.copy(), cwd="/content/stable-diffusion-webui-reForge" ) # ν”„λ‘œμ„ΈμŠ€κ°€ 끝날 λ•ŒκΉŒμ§€ κΈ°λ‹€λ¦½λ‹ˆλ‹€. return_code = process.wait() # λ§Œμ•½ μ—λŸ¬ μ½”λ“œλ₯Ό 남기고 μ£½μ—ˆλ‹€λ©΄ (보톡 1) μžλ™μœΌλ‘œ μž¬μ‹œμž‘ if return_code != 0: print(f"\n❌ μ—λŸ¬ λ°œμƒ (Exit Code: {return_code}). 2초 ν›„ μžλ™ μž¬μ‹œμž‘ν•©λ‹ˆλ‹€...") attempt += 1 time.sleep(2) continue else: # 정상 μ’…λ£Œ(0)인 경우 루프 νƒˆμΆœ print("\nβœ… WebUI μ’…λ£Œ.") break if __name__ == "__main__": run_webui()