aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-06-04 08:17:20 +0000
committerGitHub <noreply@github.com>2023-06-04 08:17:20 +0000
commit0819383de05e57ec5da638bd4d5d180b5bac981a (patch)
treeecec2c764772b337167248382fd7b72cdcef3209 /modules
parentefc4c79b5ecd0bfff09b5f7bb9acf4b9044207ae (diff)
parent333e63c0911c148ea306d7b72580d5c6d2f2c41a (diff)
downloadstable-diffusion-webui-gfx803-0819383de05e57ec5da638bd4d5d180b5bac981a.tar.gz
stable-diffusion-webui-gfx803-0819383de05e57ec5da638bd4d5d180b5bac981a.tar.bz2
stable-diffusion-webui-gfx803-0819383de05e57ec5da638bd4d5d180b5bac981a.zip
Merge pull request #10975 from AUTOMATIC1111/restart3
A yet another method to restart webui.
Diffstat (limited to 'modules')
-rw-r--r--modules/launch_utils.py6
-rw-r--r--modules/shared.py9
-rw-r--r--modules/ui_extensions.py2
3 files changed, 16 insertions, 1 deletions
diff --git a/modules/launch_utils.py b/modules/launch_utils.py
index 0c8c4db0..af8d8b37 100644
--- a/modules/launch_utils.py
+++ b/modules/launch_utils.py
@@ -244,6 +244,12 @@ def prepare_environment():
codeformer_commit_hash = os.environ.get('CODEFORMER_COMMIT_HASH', "c5b4593074ba6214284d6acd5f1719b6c5d739af")
blip_commit_hash = os.environ.get('BLIP_COMMIT_HASH', "48211a1594f1321b00f14c9f7a5b4813144b2fb9")
+ try:
+ # the existance of this file is a signal to webui.sh/bat that webui needs to be restarted when it stops execution
+ os.remove(os.path.join(script_path, "tmp", "restart"))
+ except OSError:
+ pass
+
if not args.skip_python_version_check:
check_python_version()
diff --git a/modules/shared.py b/modules/shared.py
index 53e3d5da..7d056a4d 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -852,3 +852,12 @@ def walk_files(path, allowed_extensions=None):
continue
yield os.path.join(root, filename)
+
+
+def restart_program():
+ """creates file tmp/restart and immediately stops the process, which webui.bat/webui.sh interpret as a command to start webui again"""
+
+ with open(os.path.join(script_path, "tmp", "restart"), "w"):
+ pass
+
+ os._exit(0)
diff --git a/modules/ui_extensions.py b/modules/ui_extensions.py
index 3140ed64..5580dfaf 100644
--- a/modules/ui_extensions.py
+++ b/modules/ui_extensions.py
@@ -49,7 +49,7 @@ def apply_and_restart(disable_list, update_list, disable_all):
shared.opts.disabled_extensions = disabled
shared.opts.disable_all_extensions = disable_all
shared.opts.save(shared.config_filename)
- shared.state.request_restart()
+ shared.restart_program()
def save_config_state(name):