Wrap the server operations in a single 'server' command. This will help manage the underlying engine better in the future

This commit is contained in:
cmdr2 2022-08-26 19:33:32 +05:30
parent 716ba93787
commit 3bcde36821
2 changed files with 29 additions and 4 deletions

View File

@ -23,15 +23,15 @@ All the processing will happen on your computer locally, it does not transmit yo
# Installation
1. Clone this repository: `git clone https://github.com/cmdr2/stable-diffusion-ui.git` or [download the zip file](https://github.com/cmdr2/stable-diffusion-ui/archive/refs/heads/main.zip) and unzip.
2. Open your terminal, and in the project directory run: `docker-compose up &` (warning: this will take some time during the first run, since it'll download Stable Diffusion's [docker image](https://replicate.com/stability-ai/stable-diffusion), nearly 17 GiB)
2. Open your terminal, and in the project directory run: `./server` (warning: this will take some time during the first run, since it'll download Stable Diffusion's [docker image](https://replicate.com/stability-ai/stable-diffusion), nearly 17 GiB)
3. Open http://localhost:8000 in your browser. That's it!
If you're getting errors, please check the [Troubleshooting](#troubleshooting) section below.
To stop the server, please run `docker-compose down`
To stop the server, please run `./server stop`
# Usage
Open http://localhost:8000 in your browser (after running `docker-compose up &` from step 2 previously).
Open http://localhost:8000 in your browser (after running `./server` from step 2 previously).
## With a text description
1. Enter a text prompt, like `a photograph of an astronaut riding a horse` in the textbox.
@ -72,7 +72,7 @@ If you have an NVIDIA GPU and the latest [NVIDIA driver](http://www.nvidia.com/D
## Some other process is already running at port 8000 / port 8000 could not be bound
You can override the port used. Please change `docker-compose.yml` inside the project directory, and update the line `8000:8000` to `1337:8000` (or where 1337 is whichever port number you want).
After doing this, please restart your server, by running `docker-compose down` and then `docker-compose up &`.
After doing this, please restart your server, by running `./server restart`.
After this, you can access the server at `http://localhost:1337` (where 1337 is the new port you specified earlier).

25
server Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
CMD="$1"
if [ -z "$1" ]; then
CMD="start"
fi
start_server() {
docker-compose up &
}
stop_server() {
docker-compose down
}
if [ "$CMD" == "start" ]; then
start_server
elif [ "$CMD" == "stop" ]; then
stop_server
elif [ "$CMD" == "restart" ]; then
stop_server
start_server
else
echo "Unknown option: $1 (Expected start or stop)"
fi