aboutsummaryrefslogtreecommitdiffstats
path: root/modules/restart.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-06-27 05:38:14 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-06-27 05:38:14 +0000
commit394ffa7b0a7fff3ec484bcd084e673a8b301ccc8 (patch)
treeb0e9b9d93f90b5d50084292a48578bd4f9a83ec6 /modules/restart.py
parentbaf6946e06249c5af9851c60171692c44ef633e0 (diff)
parentdbc88c96450793b08b520f3b86cd46d6aeaaae52 (diff)
downloadstable-diffusion-webui-gfx803-394ffa7b0a7fff3ec484bcd084e673a8b301ccc8.tar.gz
stable-diffusion-webui-gfx803-394ffa7b0a7fff3ec484bcd084e673a8b301ccc8.tar.bz2
stable-diffusion-webui-gfx803-394ffa7b0a7fff3ec484bcd084e673a8b301ccc8.zip
Merge branch 'release_candidate'
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)