#!/usr/bin/env bash # RAG Pipeline Service set -e cd "$(dirname "$0")" SERVICE_NAME="rag-pipeline" PORT=9093 PY=/data/ymq/wan22-service/py3/bin/python action="${1:-status}" case "$action" in deploy|update) echo "=== $SERVICE_NAME Deploy (CPU, port $PORT) ===" 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 ] && [ -f .git/HEAD ]; then git pull origin master 2>/dev/null || true fi mkdir -p logs files wwwroot pipelines data export PYTHONPATH="$(pwd)" nohup $PY ah.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/api/status > /dev/null 2>&1; then echo "Service healthy" else echo "WARNING: not responding, check nohup.out" tail -30 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 files wwwroot pipelines data export PYTHONPATH="$(pwd)" nohup $PY ah.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/api/status > /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