vdb/build.sh

69 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# vdb - Vector Database Service
set -e
cd "$(dirname "$0")"
SERVICE_NAME="vdb"
PORT=8886
PY=/data/ymq/wan22-service/py3/bin/python
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
kill $(cat ah.pid) 2>/dev/null || true
sleep 2
fi
if [ -d .git ]; then
git pull origin master 2>/dev/null || git pull origin main 2>/dev/null || true
fi
mkdir -p logs db
export PYTHONPATH="$(pwd)"
nohup $PY app/vdbapp.py > nohup.out 2>&1 &
echo $! > ah.pid
echo "Started PID $(cat ah.pid) on port $PORT"
sleep 3
if curl -s http://localhost:$PORT/v1/listcollections > /dev/null 2>&1; then
echo "Service healthy"
else
echo "WARNING: not responding yet, check nohup.out"
tail -20 nohup.out
fi
;;
stop)
if [ -f ah.pid ]; then
kill $(cat ah.pid) 2>/dev/null || true
rm -f ah.pid
echo "Stopped"
else
echo "Not running"
fi
;;
start)
mkdir -p logs db
export PYTHONPATH="$(pwd)"
nohup $PY app/vdbapp.py > nohup.out 2>&1 &
echo $! > ah.pid
echo "Started PID $(cat ah.pid)"
;;
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"
if curl -s --max-time 3 http://localhost:$PORT/v1/listcollections > /dev/null 2>&1; then
echo "HTTP: OK"
else
echo "HTTP: not responding"
fi
;;
*)
echo "Usage: $0 {deploy|update|stop|start|status}"
exit 1
;;
esac