Blame view

scripts/stop_clip_service.sh 1.09 KB
bad3b18b   tangwang   fix facet for 172
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
39
40
41
42
43
44
  #!/bin/bash
  #
  # Stop CLIP vector service (clip-as-service) started by start_clip_service.sh
  #
  set -e
  
  LOG_DIR="/home/tw/SearchEngine/logs"
  PID_FILE="${LOG_DIR}/clip_service.pid"
  
  echo "========================================"
  echo "Stopping CLIP vector service (clip-as-service)"
  echo "========================================"
  
  if [ ! -f "${PID_FILE}" ]; then
    echo "No PID file found at ${PID_FILE}."
    echo "clip-as-service may not be running (or was not started via start_clip_service.sh)."
    exit 0
  fi
  
  PID="$(cat "${PID_FILE}")"
  
  if [ -z "${PID}" ]; then
    echo "PID file exists but is empty. Removing it."
    rm -f "${PID_FILE}"
    exit 0
  fi
  
  if ps -p "${PID}" > /dev/null 2>&1; then
    echo "Sending SIGTERM to clip-as-service (PID ${PID})..."
    kill "${PID}" || true
    sleep 1
  
    if ps -p "${PID}" > /dev/null 2>&1; then
      echo "Process still alive, sending SIGKILL..."
      kill -9 "${PID}" || true
    fi
  
    echo "clip-as-service (PID ${PID}) has been stopped."
  else
    echo "No process with PID ${PID} found. Assuming it's already stopped."
  fi
  
  rm -f "${PID_FILE}"
  echo "PID file removed: ${PID_FILE}"