data / reforge_launcher.py
arcacolab's picture
Rename reforge_launcher (1).py to reforge_launcher.py
f0a57f2 verified
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()