aboutsummaryrefslogtreecommitdiff
path: root/modules/restart.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-06-27 09:23:15 +0300
committerGitHub <noreply@github.com>2023-06-27 09:23:15 +0300
commit0b97ae2832a89b103be1c062d7778e558732712f (patch)
tree6d0966156f1cfa78aa0e97ed0474afaffc50f2cd /modules/restart.py
parent7e2d39a2d158d1426321686b05d31a3ea694a99e (diff)
parent3cd4fd51ef916aba8b978490569a5da82795a839 (diff)
Merge branch 'dev' into master
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)