mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-07-21 21:01:24 +08:00
29 lines
636 B
Python
29 lines
636 B
Python
import os
|
|
from pathlib import Path
|
|
|
|
from modules.paths_internal import script_path
|
|
|
|
|
|
def is_restartable() -> bool:
|
|
"""
|
|
Return True if the webui is restartable (i.e. there is something watching to restart it with)
|
|
"""
|
|
return bool(os.environ.get("SD_WEBUI_RESTART"))
|
|
|
|
|
|
def restart_program():
|
|
"""
|
|
creates file tmp/restart and immediately stops the process,
|
|
which webui.bat/webui.sh interpret as a command to start webui again
|
|
"""
|
|
|
|
tmpdir = Path(script_path) / "tmp"
|
|
tmpdir.mkdir(parents=True, exist_ok=True)
|
|
(tmpdir / "restart").touch()
|
|
|
|
stop_program()
|
|
|
|
|
|
def stop_program():
|
|
os._exit(0)
|