47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ACTION="${1:-all}"
|
|
GPU="${2:-2}"
|
|
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
start_backend() {
|
|
echo "=== Starting Backend (vLLM) on GPU $GPU ==="
|
|
source /home/kxqandccx/miniconda3/bin/activate agent_use
|
|
CUDA_VISIBLE_DEVICES="$GPU" nohup python "$PROJECT_DIR/server.py" \
|
|
> "$PROJECT_DIR/server.log" 2>&1 &
|
|
echo "Backend PID=$!"
|
|
|
|
echo "Waiting for backend..."
|
|
for i in $(seq 1 60); do
|
|
if curl -s http://127.0.0.1:8000/v1/models > /dev/null 2>&1; then
|
|
echo "Backend ready!"
|
|
return
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "Backend failed to start"
|
|
exit 1
|
|
}
|
|
|
|
start_frontend() {
|
|
echo "=== Starting Frontend (opencode web) ==="
|
|
cd "$PROJECT_DIR"
|
|
nohup opencode web --port 3000 > /tmp/opencode-web.log 2>&1 &
|
|
echo "Frontend PID=$!"
|
|
echo "Web interface: http://127.0.0.1:3000/"
|
|
}
|
|
|
|
case "$ACTION" in
|
|
backend) start_backend ;;
|
|
frontend) start_frontend ;;
|
|
all) start_backend; start_frontend ;;
|
|
*)
|
|
echo "Usage: $0 [backend|frontend|all] [GPU]"
|
|
echo " ./start.sh # start both"
|
|
echo " ./start.sh backend # start backend only"
|
|
echo " ./start.sh frontend # start frontend only"
|
|
echo " ./start.sh all 3 # both on GPU 3"
|
|
;;
|
|
esac
|