From 1411a6e74b2fa07ecfc2117d774520f957651145 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 6 Jun 2023 00:25:28 +0900 Subject: [PATCH 1/3] rework-disable-autolaunch --- modules/launch_utils.py | 1 + webui.py | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/launch_utils.py b/modules/launch_utils.py index af8d8b378..59008385f 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -247,6 +247,7 @@ def prepare_environment(): 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")) + os.environ.setdefault('SD_WEBUI_DISABLE_AUTOLAUNCH', '1') except OSError: pass diff --git a/webui.py b/webui.py index 254fada3d..1ee0e41d4 100644 --- a/webui.py +++ b/webui.py @@ -396,7 +396,7 @@ def webui(): ssl_verify=cmd_opts.disable_tls_verify, debug=cmd_opts.gradio_debug, auth=gradio_auth_creds, - inbrowser=cmd_opts.autolaunch, + inbrowser=cmd_opts.autolaunch and os.getenv('SD_WEBUI_DISABLE_AUTOLAUNCH') != '1', prevent_thread_lock=True, allowed_paths=cmd_opts.gradio_allowed_path, app_kwargs={ @@ -407,9 +407,6 @@ def webui(): if cmd_opts.add_stop_route: app.add_route("/_stop", stop_route, methods=["POST"]) - # after initial launch, disable --autolaunch for subsequent restarts - cmd_opts.autolaunch = False - startup_timer.record("gradio launch") # gradio uses a very open CORS policy via app.user_middleware, which makes it possible for From eaace155cebeb4e713fc6f232261eeed6b958736 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 6 Jun 2023 02:47:18 +0900 Subject: [PATCH 2/3] restore old disable --autolaunch --- webui.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webui.py b/webui.py index 1ee0e41d4..58482cf41 100644 --- a/webui.py +++ b/webui.py @@ -407,6 +407,9 @@ def webui(): if cmd_opts.add_stop_route: app.add_route("/_stop", stop_route, methods=["POST"]) + # after initial launch, disable --autolaunch for subsequent restarts + cmd_opts.autolaunch = False + startup_timer.record("gradio launch") # gradio uses a very open CORS policy via app.user_middleware, which makes it possible for From c2808f3040babbb5b9456d15aa2a9354c1c64d23 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Tue, 6 Jun 2023 02:52:05 +0900 Subject: [PATCH 3/3] SD_WEBUI_RESTARTING --- modules/launch_utils.py | 2 +- webui.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/launch_utils.py b/modules/launch_utils.py index 59008385f..609a181e0 100644 --- a/modules/launch_utils.py +++ b/modules/launch_utils.py @@ -247,7 +247,7 @@ def prepare_environment(): 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")) - os.environ.setdefault('SD_WEBUI_DISABLE_AUTOLAUNCH', '1') + os.environ.setdefault('SD_WEBUI_RESTARTING ', '1') except OSError: pass diff --git a/webui.py b/webui.py index 58482cf41..136d036d5 100644 --- a/webui.py +++ b/webui.py @@ -396,7 +396,7 @@ def webui(): ssl_verify=cmd_opts.disable_tls_verify, debug=cmd_opts.gradio_debug, auth=gradio_auth_creds, - inbrowser=cmd_opts.autolaunch and os.getenv('SD_WEBUI_DISABLE_AUTOLAUNCH') != '1', + inbrowser=cmd_opts.autolaunch and os.getenv('SD_WEBUI_RESTARTING ') != '1', prevent_thread_lock=True, allowed_paths=cmd_opts.gradio_allowed_path, app_kwargs={