aboutsummaryrefslogtreecommitdiffstats
path: root/modules/restart.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2023-06-09 19:48:18 +0000
committerAUTOMATIC <16777216c@gmail.com>2023-06-09 19:48:18 +0000
commit3b11f17a374520e493e120e7f47443acd97393c8 (patch)
tree743d96990f646fb49ff377a67849c288c31e177e /modules/restart.py
parentbaf6946e06249c5af9851c60171692c44ef633e0 (diff)
parent59419bd64a1581caccaac04dceb66c1c069a2db1 (diff)
downloadstable-diffusion-webui-gfx803-3b11f17a374520e493e120e7f47443acd97393c8.tar.gz
stable-diffusion-webui-gfx803-3b11f17a374520e493e120e7f47443acd97393c8.tar.bz2
stable-diffusion-webui-gfx803-3b11f17a374520e493e120e7f47443acd97393c8.zip
Merge branch 'dev' into 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)