File size: 896 Bytes
547190f
 
 
 
 
 
d9b3f79
547190f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
set -euo pipefail

# Enable expressive model if the weight exists
if [[ -f "models/Seamless/pretssel_melhifigan_wm.pt" ]]; then
  export USE_EXPRESSIVE_MODEL=1
fi

HOST="${HOST:-0.0.0.0}"
PORT="${PORT:-7860}"

# If you use websockets / in-memory pubsub, multiple workers can break things.
# Keep default 1, but allow override.
WORKERS="${UVICORN_WORKERS:-1}"

# If behind a reverse proxy, these help with client IP / scheme
PROXY_HEADERS="${UVICORN_PROXY_HEADERS:-true}"

ARGS=(app_pubsub:app --host "$HOST" --port "$PORT" --log-level "${UVICORN_LOG_LEVEL:-info}" --timeout-keep-alive "${UVICORN_KEEPALIVE:-75}")

if [[ "$PROXY_HEADERS" == "true" ]]; then
  ARGS+=(--proxy-headers --forwarded-allow-ips "*")
fi

# Only set workers if explicitly >1 (safer default for websocket apps)
if [[ "$WORKERS" -gt 1 ]]; then
  ARGS+=(--workers "$WORKERS")
fi

exec uvicorn "${ARGS[@]}"