mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
With delta streaming most websocket frames are tiny per-token deltas, and per-message-deflate pays zlib work on every outgoing frame per subscriber for near-zero gain there; under heavy streaming that shows up as measurable server CPU. The frames that still benefit are the rare large ones (final message, sources), and even a 100k token message is only a few hundred KB uncompressed, which any network delivers without noticeable delay. UVICORN_WS_PER_MESSAGE_DEFLATE=false (default true, current behavior) disables the extension in every entry point: open-webui serve and dev, start.sh both invocations, start_windows.bat and dev.sh. Verified against a running instance: with the flag off the server declines the client-offered permessage-deflate extension, with defaults it still negotiates it.
60 lines
2.4 KiB
Batchfile
60 lines
2.4 KiB
Batchfile
:: This method is not recommended, and we recommend you use the `start.sh` file with WSL instead.
|
|
@echo off
|
|
SETLOCAL ENABLEDELAYEDEXPANSION
|
|
|
|
:: Get the directory of the current script
|
|
SET "SCRIPT_DIR=%~dp0"
|
|
cd /d "%SCRIPT_DIR%" || exit /b
|
|
|
|
:: Add conditional Playwright browser installation
|
|
IF /I "%WEB_LOADER_ENGINE%" == "playwright" (
|
|
IF "%PLAYWRIGHT_WS_URL%" == "" (
|
|
echo Installing Playwright browsers...
|
|
playwright install chromium
|
|
playwright install-deps chromium
|
|
)
|
|
|
|
python -c "import nltk; nltk.download('punkt_tab')"
|
|
)
|
|
|
|
SET "KEY_FILE=.webui_secret_key"
|
|
IF NOT "%WEBUI_SECRET_KEY_FILE%" == "" (
|
|
SET "KEY_FILE=%WEBUI_SECRET_KEY_FILE%"
|
|
)
|
|
|
|
IF "%PORT%"=="" SET PORT=8080
|
|
IF "%HOST%"=="" SET HOST=0.0.0.0
|
|
IF "%FORWARDED_ALLOW_IPS%"=="" SET "FORWARDED_ALLOW_IPS='*'"
|
|
SET "WEBUI_SECRET_KEY=%WEBUI_SECRET_KEY%"
|
|
SET "WEBUI_JWT_SECRET_KEY=%WEBUI_JWT_SECRET_KEY%"
|
|
IF "%WEBUI_SECRET_KEY_LENGTH%" == "" (
|
|
SET "WEBUI_SECRET_KEY_LENGTH=24"
|
|
)
|
|
|
|
:: Check if WEBUI_SECRET_KEY and WEBUI_JWT_SECRET_KEY are not set
|
|
IF "%WEBUI_SECRET_KEY% %WEBUI_JWT_SECRET_KEY%" == " " (
|
|
echo Loading WEBUI_SECRET_KEY from file, not provided as an environment variable.
|
|
|
|
IF NOT EXIST "!KEY_FILE!" (
|
|
echo Generating WEBUI_SECRET_KEY
|
|
:: Generate a random value to use as a WEBUI_SECRET_KEY in case the user didn't provide one
|
|
SET "CHARSET=0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
SET "WEBUI_SECRET_KEY="
|
|
FOR /L %%i IN (1,1,!WEBUI_SECRET_KEY_LENGTH!) DO (
|
|
SET /A "INDEX=!RANDOM! %% 62"
|
|
FOR %%j IN (!INDEX!) DO SET "WEBUI_SECRET_KEY=!WEBUI_SECRET_KEY!!CHARSET:~%%j,1!"
|
|
)
|
|
<nul SET /p="!WEBUI_SECRET_KEY!">"!KEY_FILE!"
|
|
echo WEBUI_SECRET_KEY generated
|
|
)
|
|
|
|
echo Loading WEBUI_SECRET_KEY from !KEY_FILE!
|
|
SET /p WEBUI_SECRET_KEY=<"!KEY_FILE!"
|
|
)
|
|
|
|
:: Execute uvicorn
|
|
SET "WEBUI_SECRET_KEY=%WEBUI_SECRET_KEY%"
|
|
IF "%UVICORN_WORKERS%"=="" SET UVICORN_WORKERS=1
|
|
if "%UVICORN_WS_PER_MESSAGE_DEFLATE%" == "" set "UVICORN_WS_PER_MESSAGE_DEFLATE=true"
|
|
uvicorn open_webui.main:app --host "%HOST%" --port "%PORT%" --forwarded-allow-ips %FORWARDED_ALLOW_IPS% --workers %UVICORN_WORKERS% --ws auto --ws-per-message-deflate %UVICORN_WS_PER_MESSAGE_DEFLATE%
|
|
:: For ssl user uvicorn open_webui.main:app --host "%HOST%" --port "%PORT%" --forwarded-allow-ips '*' --ssl-keyfile "key.pem" --ssl-certfile "cert.pem" --ws auto
|