Blame view

scripts/start_embedding_service.sh 1.14 KB
7bfb9946   tangwang   向量化模块
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
32
33
34
35
36
37
38
  #!/bin/bash
  #
  # Start Local Embedding Service
  #
  # This service exposes:
  # - POST /embed/text
  # - POST /embed/image
  #
  # Defaults are defined in `embeddings/config.py`
  #
  set -e
  
  cd "$(dirname "$0")/.."
  
  # Load conda env if available (keep consistent with other scripts)
  if [ -f "/home/tw/miniconda3/etc/profile.d/conda.sh" ]; then
    source /home/tw/miniconda3/etc/profile.d/conda.sh
    conda activate searchengine
  fi
  
  EMBEDDING_SERVICE_HOST=$(python -c "from embeddings.config import CONFIG; print(CONFIG.HOST)")
  EMBEDDING_SERVICE_PORT=$(python -c "from embeddings.config import CONFIG; print(CONFIG.PORT)")
  
  echo "========================================"
  echo "Starting Local Embedding Service"
  echo "========================================"
  echo "Host: ${EMBEDDING_SERVICE_HOST}"
  echo "Port: ${EMBEDDING_SERVICE_PORT}"
  echo
  echo "Tips:"
  echo "  - Use a single worker (GPU models cannot be safely duplicated across workers)."
  echo "  - Clients can set EMBEDDING_SERVICE_URL=http://localhost:${EMBEDDING_SERVICE_PORT}"
  echo
  
  exec python -m uvicorn embeddings.server:app \
    --host "${EMBEDDING_SERVICE_HOST}" \
    --port "${EMBEDDING_SERVICE_PORT}" \
    --workers 1