aboutsummaryrefslogtreecommitdiffstats
path: root/modules/restart.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-06-27 06:05:53 +0000
committerGitHub <noreply@github.com>2023-06-27 06:05:53 +0000
commit4147fd6b2f905f76c6bc20c3d9de2ea0842fa853 (patch)
treee7915af4d068912cd8509f1638e05460445a5eea /modules/restart.py
parentf603275d84301b5ee952683e951dd1aad72ba615 (diff)
parentbedcd2f377a38ef4da58c11dbe222d32b954be2f (diff)
downloadstable-diffusion-webui-gfx803-4147fd6b2f905f76c6bc20c3d9de2ea0842fa853.tar.gz
stable-diffusion-webui-gfx803-4147fd6b2f905f76c6bc20c3d9de2ea0842fa853.tar.bz2
stable-diffusion-webui-gfx803-4147fd6b2f905f76c6bc20c3d9de2ea0842fa853.zip
Merge branch 'dev' into 10141-gradio-user-exif
Diffstat (limited to 'modules/restart.py')
-rw-r--r--modules/restart.py23
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)