clip_embedding/build.sh

59 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
cd "$(dirname "$0")"
SERVICE_NAME="clip_embedding"
PORT=9086
DEFAULT_GPU=2
action="${1:-status}"
case "$action" in
deploy|update)
echo "=== $SERVICE_NAME Deploy ==="
if [ -f ah.pid ] && kill -0 $(cat ah.pid) 2>/dev/null; then
bash stop.sh
sleep 2
fi
if [ -d .git ]; then
echo "Pulling latest code..."
git pull origin master 2>/dev/null || git pull origin main 2>/dev/null || true
fi
export CLIP_GPU_ID="${CLIP_GPU_ID:-$DEFAULT_GPU}"
bash start.sh
sleep 3
if curl -s http://localhost:$PORT/api/status > /dev/null 2>&1; then
echo "Service is healthy on port $PORT"
curl -s http://localhost:$PORT/api/status | python3 -m json.tool 2>/dev/null || true
else
echo "WARNING: Service may not be ready yet. Check nohup.out"
fi
;;
stop)
bash stop.sh
;;
start)
export CLIP_GPU_ID="${CLIP_GPU_ID:-$DEFAULT_GPU}"
bash start.sh
;;
status)
echo "=== $SERVICE_NAME Status ==="
if [ -f ah.pid ] && kill -0 $(cat ah.pid) 2>/dev/null; then
echo "Process: running (PID $(cat ah.pid))"
else
echo "Process: not running"
fi
echo "Port: $PORT"
echo "GPU: ${CLIP_GPU_ID:-$DEFAULT_GPU}"
if curl -s --max-time 3 http://localhost:$PORT/api/status > /dev/null 2>&1; then
echo "HTTP: OK"
curl -s http://localhost:$PORT/api/status | python3 -m json.tool 2>/dev/null || true
else
echo "HTTP: not responding"
fi
;;
*)
echo "Usage: $0 {deploy|update|stop|start|status}"
exit 1
;;
esac