#!/bin/bash # # Stop CLIP vector service (clip-as-service) started by start_clip_service.sh # set -e LOG_DIR="/home/tw/saas-search/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}"