Semnykcz commited on
Commit
07bb64b
·
verified ·
1 Parent(s): c67024e

Update start.sh

Browse files
Files changed (1) hide show
  1. start.sh +27 -10
start.sh CHANGED
@@ -1,23 +1,40 @@
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
 
 
4
  echo "[start] MODELS_DIR=${MODELS_DIR:-/grpc-models}"
5
  echo "[start] MODEL_URLS length: ${#MODEL_URLS}"
 
 
6
 
7
- # 1) Optional: download models listed in env MODEL_URLS
8
  /srv/model_download.sh || true
9
 
10
- # 2) Start the Draw Things gRPC server (non-blocking)
11
  /usr/local/bin/gRPCServerCLI "${MODELS_DIR}" &
12
  SERVER_PID=$!
13
- echo "[start] gRPCServerCLI started (pid=${SERVER_PID}) on 127.0.0.1:${GRPC_PORT}"
14
 
15
- # 3) Forward Hugging Face public $PORT -> local ${GRPC_PORT}
16
- if [[ -z "${PORT:-}" ]]; then
17
- echo "[start][warn] \$PORT not set by runtime. Defaulting to 7860."
18
- PORT=7860
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  fi
20
 
21
- echo "[start] Forwarding public :${PORT} -> 127.0.0.1:${GRPC_PORT}"
22
- # -socat- will keep running in foreground as PID 1
23
- exec socat TCP-LISTEN:${PORT},fork,reuseaddr TCP:127.0.0.1:${GRPC_PORT}
 
1
  #!/usr/bin/env bash
2
  set -euo pipefail
3
 
4
+ PORT="${PORT:-7860}"
5
+ GRPC_PORT="${GRPC_PORT:-7859}"
6
  echo "[start] MODELS_DIR=${MODELS_DIR:-/grpc-models}"
7
  echo "[start] MODEL_URLS length: ${#MODEL_URLS}"
8
+ echo "[start] GRPC_PORT=${GRPC_PORT}"
9
+ echo "[start] Public PORT (HF)=${PORT}"
10
 
11
+ # 1) Optional: stáhni modely
12
  /srv/model_download.sh || true
13
 
14
+ # 2) Start gRPC server (na pozadí)
15
  /usr/local/bin/gRPCServerCLI "${MODELS_DIR}" &
16
  SERVER_PID=$!
17
+ echo "[start] gRPCServerCLI started (pid=${SERVER_PID}) target=127.0.0.1:${GRPC_PORT}"
18
 
19
+ # 3) Počkej začne naslouchat (max ~30s)
20
+ for i in {1..60}; do
21
+ if nc -z 127.0.0.1 "${GRPC_PORT}" 2>/dev/null; then
22
+ echo "[start] gRPCServerCLI is up."
23
+ break
24
+ fi
25
+ echo "[start] waiting gRPCServerCLI..."
26
+ sleep 0.5
27
+ done
28
+
29
+ # 4) Přepiš port v Envoy YAML (placeholder 7860 → $PORT)
30
+ if [[ "${PORT}" != "7860" ]]; then
31
+ sed -i "s/port_value: 7860/port_value: ${PORT}/g" /srv/envoy.yaml
32
+ fi
33
+ # A pro jistotu přepiš upstream port (placeholder 7859 → $GRPC_PORT), kdyby ses rozhodl změnit
34
+ if [[ "${GRPC_PORT}" != "7859" ]]; then
35
+ sed -i "s/port_value: 7859/port_value: ${GRPC_PORT}/g" /srv/envoy.yaml
36
  fi
37
 
38
+ # 5) Spusť Envoy v popředí (PID 1)
39
+ echo "[start] starting Envoy on :${PORT} 127.0.0.1:${GRPC_PORT} (h1/h2c → h2)"
40
+ exec /usr/local/bin/envoy -c /srv/envoy.yaml -l info