From f969bfa7be27ede0da83f721464026a05e124439 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Sat, 5 Nov 2022 18:59:59 +0100 Subject: [PATCH 1/3] More error handling, central error function --- build.sh | 1 + scripts/bootstrap.sh | 22 ++++++--- scripts/functions.sh | 30 +++++++++++++ scripts/on_env_start.sh | 6 +-- scripts/on_sd_start.sh | 99 +++++++++++++---------------------------- scripts/start.sh | 6 +-- 6 files changed, 86 insertions(+), 78 deletions(-) create mode 100644 scripts/functions.sh diff --git a/build.sh b/build.sh index dc4a5047..f4538e5c 100755 --- a/build.sh +++ b/build.sh @@ -28,6 +28,7 @@ mkdir -p dist/linux-mac/stable-diffusion-ui/scripts cp scripts/on_env_start.sh dist/linux-mac/stable-diffusion-ui/scripts/ cp scripts/bootstrap.sh dist/linux-mac/stable-diffusion-ui/scripts/ +cp scripts/functions.sh dist/linux-mac/stable-diffusion-ui/scripts/ cp scripts/start.sh dist/linux-mac/stable-diffusion-ui/ cp LICENSE dist/linux-mac/stable-diffusion-ui/ cp "CreativeML Open RAIL-M License" dist/linux-mac/stable-diffusion-ui/ diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index e497f953..d0b1312b 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -6,6 +6,9 @@ # This enables a user to install this project without manually installing conda and git. +source ./scripts/functions.sh + +set -o pipefail OS_NAME=$(uname -s) case "${OS_NAME}" in @@ -49,6 +52,13 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then mkdir -p "$MAMBA_ROOT_PREFIX" curl -L "$MICROMAMBA_DOWNLOAD_URL" | tar -xvj bin/micromamba -O > "$MAMBA_ROOT_PREFIX/micromamba" + if [ "$?" != "0" ]; then + echo + echo "EE micromamba download failed" + echo "EE If the lines above contain 'bzip2: Cannot exec', your system doesn't have bzip2 installed" + echo "EE If there are network errors, please check your internet setup" + fail "micromamba download failed" + fi chmod u+x "$MAMBA_ROOT_PREFIX/micromamba" @@ -59,15 +69,17 @@ if [ "$PACKAGES_TO_INSTALL" != "" ]; then # create the installer env if [ ! -e "$INSTALL_ENV_DIR" ]; then - "$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR" + "$MAMBA_ROOT_PREFIX/micromamba" create -y --prefix "$INSTALL_ENV_DIR" || fail "unable to create the install environment" + fi + + if [ ! -e "$INSTALL_ENV_DIR" ]; then + fail "There was a problem while installing$PACKAGES_TO_INSTALL using micromamba. Cannot continue." fi echo "Packages to install:$PACKAGES_TO_INSTALL" "$MAMBA_ROOT_PREFIX/micromamba" install -y --prefix "$INSTALL_ENV_DIR" -c conda-forge $PACKAGES_TO_INSTALL - - if [ ! -e "$INSTALL_ENV_DIR" ]; then - echo "There was a problem while installing$PACKAGES_TO_INSTALL using micromamba. Cannot continue." - exit + if [ "$?" != "0" ]; then + fail "Installation of the packages '$PACKAGES_TO_INSTALL' failed." fi fi diff --git a/scripts/functions.sh b/scripts/functions.sh new file mode 100644 index 00000000..55f0e84e --- /dev/null +++ b/scripts/functions.sh @@ -0,0 +1,30 @@ +# +# utility functions for all scripts +# + +fail() { + echo "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + if [ "$1" != "" ]; then + echo ERROR: $1 + else + echo An error occurred. + fi + cat <> scripts/install_status.txt else - printf "\n\nError downloading Stable Diffusion UI. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "git clone failed" fi fi diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index 4bf5d79a..a5c6c8d4 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -1,5 +1,7 @@ #!/bin/bash +source ./scripts/functions.sh + cp sd-ui-files/scripts/on_env_start.sh scripts/ cp sd-ui-files/scripts/bootstrap.sh scripts/ @@ -7,14 +9,14 @@ cp sd-ui-files/scripts/bootstrap.sh scripts/ CONDA_BASEPATH=$(conda info --base) source "$CONDA_BASEPATH/etc/profile.d/conda.sh" # avoids the 'shell not initialized' error -conda activate +conda activate || fail "Failed to activate conda" # remove the old version of the dev console script, if it's still present if [ -e "open_dev_console.sh" ]; then rm "open_dev_console.sh" fi -python -c "import os; import shutil; frm = 'sd-ui-files/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'; dst = os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'transformers', '9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'); shutil.copyfile(frm, dst) if os.path.exists(dst) else print(''); print('Hotfixed broken JSON file from OpenAI');" +python -c "import os; import shutil; frm = 'sd-ui-files/ui/hotfix/9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'; dst = os.path.join(os.path.expanduser('~'), '.cache', 'huggingface', 'transformers', '9c24e6cd9f499d02c4f21a033736dabd365962dc80fe3aeb57a8f85ea45a20a3.26fead7ea4f0f843f6eb4055dfd25693f1a71f3c6871b184042d4b126244e142'); shutil.copyfile(frm, dst) if os.path.exists(dst) else print(''); print('Hotfixed broken JSON file from OpenAI');" # Caution, this file will make your eyes and brain bleed. It's such an unholy mess. # Note to self: Please rewrite this in Python. For the sake of your own sanity. @@ -28,8 +30,8 @@ if [ -e "scripts/install_status.txt" ] && [ `grep -c sd_git_cloned scripts/insta git pull git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply ../ui/sd_internal/ddim_callback.patch - git apply ../ui/sd_internal/env_yaml.patch + git apply ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. else @@ -38,16 +40,14 @@ else if git clone https://github.com/basujindal/stable-diffusion.git ; then echo sd_git_cloned >> scripts/install_status.txt else - printf "\n\nError downloading Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "git clone of basujindal/stable-diffusion.git failed" fi cd stable-diffusion git -c advice.detachedHead=false checkout f6cfebffa752ee11a7b07497b8529d5971de916c - git apply ../ui/sd_internal/ddim_callback.patch - git apply ../ui/sd_internal/env_yaml.patch + git apply ../ui/sd_internal/ddim_callback.patch || fail "ddim patch failed" + git apply ../ui/sd_internal/env_yaml.patch || fail "yaml patch failed" cd .. fi @@ -57,7 +57,7 @@ cd stable-diffusion if [ `grep -c conda_sd_env_created ../scripts/install_status.txt` -gt "0" ]; then echo "Packages necessary for Stable Diffusion were already installed" - conda activate ./env + conda activate ./env || fail "conda activate failed" else printf "\n\nDownloading packages necessary for Stable Diffusion..\n" printf "\n\n***** This will take some time (depending on the speed of the Internet connection) and may appear to be stuck, but please be patient ***** ..\n\n" @@ -68,26 +68,20 @@ else if conda env create --prefix env --force -f environment.yaml ; then echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "'conda env create' failed" fi - conda activate ./env + conda activate ./env || fail "conda activate failed" if conda install -c conda-forge --prefix ./env -y antlr4-python3-runtime=4.8 ; then echo "Installed. Testing.." else - printf "\n\nError installing antlr4-python3-runtime for Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error installing antlr4-python3-runtime" fi out_test=`python -c "import torch; import ldm; import transformers; import numpy; import antlr4; print(42)"` if [ "$out_test" != "42" ]; then - printf "\n\nDependency test failed! Error installing the packages necessary for Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Dependency test failed" fi echo conda_sd_env_created >> ../scripts/install_status.txt @@ -103,16 +97,15 @@ else if pip install -e git+https://github.com/TencentARC/GFPGAN#egg=GFPGAN ; then echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error installing the packages necessary for GFPGAN (Face Correction)." fi out_test=`python -c "from gfpgan import GFPGANer; print(42)"` if [ "$out_test" != "42" ]; then - printf "\n\nDependency test failed! Error installing the packages necessary for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + echo "EE The dependency check has failed. This usually means that some system libraries are missing." + echo "EE On Debian/Ubuntu systems, this are often these packages: libsm6 libxext6 libxrender-dev" + echo "EE Other Linux distributions might have different package names for these libraries." + fail "GFPGAN dependency test failed" fi echo conda_sd_gfpgan_deps_installed >> ../scripts/install_status.txt @@ -128,16 +121,12 @@ else if pip install -e git+https://github.com/xinntao/Real-ESRGAN#egg=realesrgan ; then echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error installing the packages necessary for ESRGAN" fi out_test=`python -c "from basicsr.archs.rrdbnet_arch import RRDBNet; from realesrgan import RealESRGANer; print(42)"` if [ "$out_test" != "42" ]; then - printf "\n\nDependency test failed! Error installing the packages necessary for ESRGAN (Resolution Upscaling). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "ESRGAN dependency test failed" fi echo conda_sd_esrgan_deps_installed >> ../scripts/install_status.txt @@ -153,15 +142,11 @@ else if conda install -c conda-forge --prefix ./env -y uvicorn fastapi ; then echo "Installed. Testing.." else - printf "\n\nError installing the packages necessary for Stable Diffusion UI. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "'conda install uvicorn' failed" fi if ! command -v uvicorn &> /dev/null; then - printf "\n\nUI packages not found! Error installing the packages necessary for Stable Diffusion UI. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "UI packages not found!" fi echo conda_sd_ui_deps_installed >> ../scripts/install_status.txt @@ -191,15 +176,10 @@ if [ ! -f "sd-v1-4.ckpt" ]; then if [ -f "sd-v1-4.ckpt" ]; then model_size=`find "sd-v1-4.ckpt" -printf "%s"` if [ ! "$model_size" == "4265380512" ]; then - printf "\n\nError: The downloaded model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "The downloaded model file was invalid! Bytes downloaded: $model_size" fi else - printf "\n\nError downloading the data files (weights) for Stable Diffusion. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error downloading the data files (weights) for Stable Diffusion" fi fi @@ -223,15 +203,10 @@ if [ ! -f "GFPGANv1.3.pth" ]; then if [ -f "GFPGANv1.3.pth" ]; then model_size=`find "GFPGANv1.3.pth" -printf "%s"` if [ ! "$model_size" -eq "348632874" ]; then - printf "\n\nError: The downloaded GFPGAN model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "The downloaded GFPGAN model file was invalid! Bytes downloaded: $model_size" fi else - printf "\n\nError downloading the data files (weights) for GFPGAN (Face Correction). Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error downloading the data files (weights) for GFPGAN (Face Correction)." fi fi @@ -255,15 +230,10 @@ if [ ! -f "RealESRGAN_x4plus.pth" ]; then if [ -f "RealESRGAN_x4plus.pth" ]; then model_size=`find "RealESRGAN_x4plus.pth" -printf "%s"` if [ ! "$model_size" -eq "67040989" ]; then - printf "\n\nError: The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "The downloaded ESRGAN x4plus model file was invalid! Bytes downloaded: $model_size" fi else - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus" fi fi @@ -287,15 +257,10 @@ if [ ! -f "RealESRGAN_x4plus_anime_6B.pth" ]; then if [ -f "RealESRGAN_x4plus_anime_6B.pth" ]; then model_size=`find "RealESRGAN_x4plus_anime_6B.pth" -printf "%s"` if [ ! "$model_size" -eq "17938799" ]; then - printf "\n\nError: The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: $model_size\n\n" - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "The downloaded ESRGAN x4plus_anime model file was invalid! Bytes downloaded: $model_size" fi else - printf "\n\nError downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime. Sorry about that, please try to:\n 1. Run this installer again.\n 2. If that doesn't fix it, please try the common troubleshooting steps at https://github.com/cmdr2/stable-diffusion-ui/wiki/Troubleshooting\n 3. If those steps don't help, please copy *all* the error messages in this window, and ask the community at https://discord.com/invite/u9yhsFmEkB\n 4. If that doesn't solve the problem, please file an issue at https://github.com/cmdr2/stable-diffusion-ui/issues\nThanks!\n\n" - read -p "Press any key to continue" - exit + fail "Error downloading the data files (weights) for ESRGAN (Resolution Upscaling) x4plus_anime." fi fi @@ -318,6 +283,6 @@ cd .. export SD_UI_PATH=`pwd`/ui cd stable-diffusion -uvicorn server:app --app-dir "$SD_UI_PATH" --port 9000 --host 0.0.0.0 +uvicorn server:app --app-dir "$SD_UI_PATH" --port ${SDUI_BIND_PORT:-9000} --host ${SDUI_BIND_IP:-0.0.0.0} read -p "Press any key to continue" diff --git a/scripts/start.sh b/scripts/start.sh index 14093681..4bb6cb66 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -6,17 +6,17 @@ cd "$(dirname "${BASH_SOURCE[0]}")" if [ -e "installer" ]; then export PATH="$(pwd)/installer/bin:$PATH"; fi # Setup the packages required for the installer -scripts/bootstrap.sh +scripts/bootstrap.sh || exit 1 # set new installer's PATH, if it downloaded any packages if [ -e "installer_files/env" ]; then export PATH="$(pwd)/installer_files/env/bin:$PATH"; fi # Test the bootstrap which git -git --version +git --version || exit 1 which conda -conda --version +conda --version || exit 1 # Download the rest of the installer and UI scripts/on_env_start.sh From cfa6dc783623753d9a9021cf66e3a5df57a971b5 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Sat, 5 Nov 2022 19:02:19 +0100 Subject: [PATCH 2/3] Add blank lines to error message --- scripts/functions.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/functions.sh b/scripts/functions.sh index 55f0e84e..c1732da0 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -3,7 +3,9 @@ # fail() { + echo echo "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE" + echo if [ "$1" != "" ]; then echo ERROR: $1 else From d3a90ccc0d4bdbd4af5dce4c792941e27ff8c284 Mon Sep 17 00:00:00 2001 From: JeLuF Date: Sat, 5 Nov 2022 23:30:40 +0100 Subject: [PATCH 3/3] Windows error handling - cd to the script location on start of 'Start Stable Diffusion UI.cmd' - Bail out when downloading micromamba fails - add env variables SD_UI_BIND_IP and SD_UI_BIND_PORT to configure uvicorn --- scripts/Start Stable Diffusion UI.cmd | 1 + scripts/bootstrap.bat | 6 ++++++ scripts/on_sd_start.bat | 5 ++++- scripts/on_sd_start.sh | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/Start Stable Diffusion UI.cmd b/scripts/Start Stable Diffusion UI.cmd index 7f7d0539..231a6c3d 100644 --- a/scripts/Start Stable Diffusion UI.cmd +++ b/scripts/Start Stable Diffusion UI.cmd @@ -1,5 +1,6 @@ @echo off +cd /d %~dp0 set PATH=C:\Windows\System32;%PATH% @rem set legacy installer's PATH, if it exists diff --git a/scripts/bootstrap.bat b/scripts/bootstrap.bat index 27004ca2..e334deb9 100644 --- a/scripts/bootstrap.bat +++ b/scripts/bootstrap.bat @@ -37,6 +37,12 @@ if "%PACKAGES_TO_INSTALL%" NEQ "" ( mkdir "%MAMBA_ROOT_PREFIX%" call curl -L "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe" + if "%ERRORLEVEL%" NEQ "0" ( + echo "There was a problem downloading micromamba. Cannot continue." + pause + exit /b + ) + @rem test the mamba binary echo Micromamba version: call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version diff --git a/scripts/on_sd_start.bat b/scripts/on_sd_start.bat index 3b7ed0ca..b82d48dd 100644 --- a/scripts/on_sd_start.bat +++ b/scripts/on_sd_start.bat @@ -343,6 +343,9 @@ call python --version @set SD_UI_PATH=%cd%\ui @cd stable-diffusion -@uvicorn server:app --app-dir "%SD_UI_PATH%" --port 9000 --host 0.0.0.0 +@if NOT DEFINED SD_UI_BIND_PORT set SD_UI_BIND_PORT=9000 +@if NOT DEFINED SD_UI_BIND_IP set SD_UI_BIND_PORT=0.0.0.0 +@uvicorn server:app --app-dir "%SD_UI_PATH%" --port %SD_UI_BIND_PORT% --host %SD_UI_BIND_IP% + @pause diff --git a/scripts/on_sd_start.sh b/scripts/on_sd_start.sh index a5c6c8d4..da0f2357 100755 --- a/scripts/on_sd_start.sh +++ b/scripts/on_sd_start.sh @@ -283,6 +283,6 @@ cd .. export SD_UI_PATH=`pwd`/ui cd stable-diffusion -uvicorn server:app --app-dir "$SD_UI_PATH" --port ${SDUI_BIND_PORT:-9000} --host ${SDUI_BIND_IP:-0.0.0.0} +uvicorn server:app --app-dir "$SD_UI_PATH" --port ${SD_UI_BIND_PORT:-9000} --host ${SD_UI_BIND_IP:-0.0.0.0} read -p "Press any key to continue"