diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-06-05 17:06:40 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-05 17:06:40 +0000 |
commit | 1dd8d571a4fa053633314657c78032a5b83a7cb5 (patch) | |
tree | 3b6c643d969e1dd164fbee5d835ab02d0a47d487 /modules/restart.py | |
parent | 18acc0b30d9184702a772287ed8197385e0aed98 (diff) | |
parent | 46a5bd64edece07f521409f0adace6cdd6f30a40 (diff) | |
download | stable-diffusion-webui-gfx803-1dd8d571a4fa053633314657c78032a5b83a7cb5.tar.gz stable-diffusion-webui-gfx803-1dd8d571a4fa053633314657c78032a5b83a7cb5.tar.bz2 stable-diffusion-webui-gfx803-1dd8d571a4fa053633314657c78032a5b83a7cb5.zip |
Merge pull request #11043 from akx/restart-envvar
Restart: only do restart if running via the wrapper script
Diffstat (limited to 'modules/restart.py')
-rw-r--r-- | modules/restart.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/restart.py b/modules/restart.py new file mode 100644 index 00000000..18eacaf3 --- /dev/null +++ b/modules/restart.py @@ -0,0 +1,23 @@ +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() -> None: + """creates file tmp/restart and immediately stops the process, which webui.bat/webui.sh interpret as a command to start webui again""" + + (Path(script_path) / "tmp" / "restart").touch() + + stop_program() + + +def stop_program() -> None: + os._exit(0) |